:root{
  --bg:#0a0a1a;
  --card1:#1a1a2e;
  --card2:#16213e;
  --card3:#0f3460;
  --text:#e0e0e0;
  --muted:#94a3b8;
  --muted2:#64748b;
  --line:rgba(255,255,255,.10);
  --brand:#a855f7;
  --brand2:#ec4899;
  --ok:#22c55e;
  --bad:#ef4444;
  --warn:#fbbf24;
  --shadow:0 10px 40px rgba(0,0,0,.35);
  --radius:16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

*{ box-sizing:border-box; margin:0; padding:0; }
html, body{ height:100%; background:var(--bg); color:var(--text); font-family:'Noto Sans KR', system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
button, input, select, textarea{ font-family:inherit; }

.app-header{
  position:sticky; top:0;
  padding: 12px calc(14px + var(--safe-right)) 12px calc(14px + var(--safe-left));
  padding-top: calc(12px + var(--safe-top));
  background: linear-gradient(135deg, var(--card1), var(--card2));
  border-bottom:1px solid rgba(255,255,255,.08);
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  z-index:20;
}

.deck-btn{ display:flex; flex-direction:column; align-items:flex-start; gap:2px; }
.app-title{
  font-weight:900; font-size:16px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  -webkit-background-clip:text; background-clip:text;
  -webkit-text-fill-color:transparent;
}
.deck-sub{ font-size:12px; color:var(--muted2); }

.top-stats{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.stat-chip{
  font-size:12px;
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  padding:6px 10px;
  border-radius:999px;
}
.stat-num{ font-weight:900; color:#c4b5fd; margin-left:2px; }
.stat-num.ok{ color:#4ade80; }
.stat-num.bad{ color:#f87171; }

.app-main{
  padding-bottom: calc(72px + var(--safe-bottom));
}

.view{ width:100%; max-width:760px; margin:0 auto; }

.progress-container{ padding: 10px 14px; }
.progress-bar{
  height:6px; border-radius:999px;
  background: rgba(255,255,255,.10);
  overflow:hidden;
}
.progress-fill{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, var(--brand), var(--brand2));
  transition: width .35s ease;
}
.progress-label{
  margin-top:6px;
  display:flex; justify-content:space-between;
  font-size:12px; color:var(--muted2);
}

.session-stats{
  margin: 0 14px;
  display:flex; justify-content:space-around;
  gap:8px;
  background: rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  padding: 12px 10px;
}
.session-stat{ text-align:center; }
.session-stat-value{ font-weight:900; font-size:22px; }
.session-stat-label{ font-size:11px; color:var(--muted2); margin-top:2px; }
.session-stat-value.ok{ color:#4ade80; }
.session-stat-value.time{ color:var(--warn); }
.session-stat-value.total{ color:#c4b5fd; }
.session-stat-value.streak{ color:#fb923c; }

.card-container{ padding: 10px 14px 0 14px; }
.card{
  background: linear-gradient(145deg, var(--card1) 0%, var(--card2) 50%, var(--card3) 100%);
  border:1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card-top{ display:flex; justify-content:space-between; align-items:center; gap:8px; }
.badge{
  display:inline-flex; align-items:center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size:12px;
  font-weight:800;
}
.badge.subject{
  color:#fff;
  background: rgba(99,102,241,.18);
  border:1px solid rgba(99,102,241,.30);
}
.badge.theme{
  color: var(--muted);
  background: rgba(255,255,255,.07);
  border:1px solid rgba(255,255,255,.10);
  max-width: 55%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.divider{
  height:1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.12), transparent);
  margin: 12px 0;
}

.statement{
  font-size: 17px;
  line-height: 1.85;
  font-weight:600;
  color:#f1f5f9;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.05);
  border-left: 4px solid rgba(168,85,247,.85);
  white-space: pre-wrap;
}

.hint-row{
  margin-top:12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(168,85,247,.10);
  border: 1px solid rgba(168,85,247,.25);
  font-size: 13px;
}
.hint-label{ color:#c4b5fd; font-weight:700; }
.hint-value{ color:#e9d5ff; font-weight:900; margin-left:6px; }

.timer{ margin-top: 12px; text-align:center; }
.timer-display{
  font-size: 26px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.timer-display.normal{ color: var(--brand); }
.timer-display.warning{ color: var(--warn); }
.timer-display.danger{ color: var(--bad); }
.timer-mini{ margin-top:4px; font-size:12px; color:var(--muted2); }

.ox-prompt{
  margin-top: 14px;
  display:flex; align-items:center; justify-content:center; gap:14px;
}
.ox-circle{
  width: 58px; height: 58px;
  border-radius: 50%;
  border:none;
  cursor:pointer;
  font-size: 28px;
  font-weight: 900;
  color:#fff;
  background: linear-gradient(135deg, var(--ok), #16a34a);
  box-shadow: 0 6px 18px rgba(34,197,94,.25);
  touch-action: manipulation;
}
.ox-circle:active{ transform: scale(.98); }
.ox-circle.ox-x{
  background: linear-gradient(135deg, var(--bad), #dc2626);
  box-shadow: 0 6px 18px rgba(239,68,68,.25);
}
.prompt-text{ color: var(--muted2); font-size:13px; }

.reveal-prompt{ margin-top: 16px; display:flex; flex-direction:column; align-items:center; gap:8px; }

.result-badge{
  text-align:center;
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
}
.result-badge.correct{
  background: rgba(34,197,94,.12);
  border:1px solid rgba(34,197,94,.25);
  color:#4ade80;
}
.result-badge.wrong{
  background: rgba(239,68,68,.12);
  border:1px solid rgba(239,68,68,.25);
  color:#f87171;
}
.result-badge.info{
  background: rgba(168,85,247,.12);
  border:1px solid rgba(168,85,247,.25);
  color:#e9d5ff;
}

.answer-section{ display:flex; justify-content:center; margin: 10px 0 14px 0; }
.answer-badge{
  width: 76px; height: 76px;
  border-radius: 50%;
  display:flex; align-items:center; justify-content:center;
  font-size: 44px;
  font-weight: 900;
  color:#fff;
}
.answer-badge.O{ background: linear-gradient(135deg, var(--ok), #16a34a); box-shadow: 0 10px 26px rgba(34,197,94,.25); }
.answer-badge.X{ background: linear-gradient(135deg, var(--bad), #dc2626); box-shadow: 0 10px 26px rgba(239,68,68,.25); }

.memory-tip-box{
  background: linear-gradient(135deg, rgba(168,85,247,.18), rgba(236,72,153,.12));
  border: 2px solid rgba(168,85,247,.35);
  border-radius: 14px;
  padding: 14px 14px;
  margin-bottom: 10px;
}
.memory-tip-header{ font-size: 12px; font-weight: 900; color:#c084fc; letter-spacing:.7px; margin-bottom:6px; }
.memory-tip-text{ font-size: 14px; font-weight: 700; color:#f0abfc; line-height: 1.85; }

.info-box{
  display:flex; gap:10px;
  padding: 12px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  border: 1px solid rgba(255,255,255,.08);
}
.info-ico{ width: 22px; text-align:center; }
.info-label{ font-size: 11px; font-weight: 800; letter-spacing: .8px; margin-bottom: 4px; }
.info-text{ font-size: 14px; color:#e5e7eb; line-height:1.75; font-weight:600; }
.info-box.rule{ background: rgba(34,197,94,.07); border-color: rgba(34,197,94,.20); }
.info-box.rule .info-label{ color:#4ade80; }
.info-box.confusion{ background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.22); }
.info-box.confusion .info-label{ color: var(--warn); }
.info-box.oneliner{ background: rgba(168,85,247,.08); border-color: rgba(168,85,247,.20); }
.info-box.oneliner .info-label{ color:#c4b5fd; }

.source-box{
  margin-top: 6px;
  text-align:right;
  color: var(--muted2);
  font-size: 11px;
  border-top: 1px solid rgba(255,255,255,.06);
  padding-top: 8px;
}

.card-actions{
  margin-top: 10px;
  display:flex; gap:8px;
  justify-content:flex-end;
}

.grade-bar{
  position: sticky;
  bottom: calc(56px + var(--safe-bottom));
  margin: 10px 14px 0 14px;
  display:flex; gap:8px;
}
.btn{
  border:none;
  border-radius: 12px;
  padding: 12px 12px;
  font-size: 14px;
  font-weight: 900;
  cursor:pointer;
  flex:1;
  touch-action: manipulation;
}
.btn:active{ transform: scale(.99); }
.btn-primary{
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color:#fff;
}
.btn-again{ background: linear-gradient(135deg, var(--bad), #dc2626); color:#fff; }
.btn-hard{ background: linear-gradient(135deg, #f59e0b, #d97706); color:#fff; }
.btn-good{ background: linear-gradient(135deg, var(--ok), #16a34a); color:#fff; }
.btn-easy{ background: linear-gradient(135deg, var(--brand), #7c3aed); color:#fff; }
.btn-danger{ background: linear-gradient(135deg, var(--bad), #b91c1c); color:#fff; }

.ghost{
  background: transparent;
  border: 1px solid rgba(255,255,255,.14);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 12px;
  cursor:pointer;
}
.ghost.small{ padding: 8px 10px; font-size: 12px; border-radius: 10px; }
.ghost:active{ transform: scale(.99); }

.kbd-hint{
  padding: 10px 14px 0 14px;
  text-align:center;
  color: var(--muted2);
  font-size: 11px;
}
kbd{
  display:inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  font-size: 10px;
  color: var(--text);
  margin: 0 1px;
}

.panel{
  margin: 12px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px;
  padding: 14px;
}
.panel-title{
  font-weight: 900;
  font-size: 16px;
  margin-bottom: 12px;
  color:#e9d5ff;
}
.panel-row{ display:flex; gap:8px; align-items:center; }
.filter-row{ display:flex; gap:8px; margin-top: 10px; flex-wrap:wrap; }

.input, .select, .textarea{
  width:100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 12px;
  outline:none;
}
.textarea{ resize: vertical; min-height: 140px; }
.input::placeholder, .textarea::placeholder{ color: rgba(148,163,184,.7); }
.select{ padding-right: 28px; }

.list{ margin-top: 12px; display:flex; flex-direction:column; gap:10px; }
.list-item{
  padding: 12px 12px;
  border-radius: 12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  cursor:pointer;
}
.list-item:hover{ background: rgba(255,255,255,.06); }
.li-top{ display:flex; justify-content:space-between; gap:10px; align-items:center; }
.li-title{ font-weight: 800; font-size: 13px; color:#c4b5fd; }
.li-meta{ font-size: 11px; color: var(--muted2); }
.li-snippet{ margin-top: 8px; font-size: 13px; line-height: 1.65; color: #f1f5f9; opacity:.95; }

.form-row{ margin-top: 12px; }
.label{ display:block; font-size: 12px; font-weight: 900; color: var(--muted); margin-bottom: 6px; }
.help{ margin-top: 6px; font-size: 11px; color: var(--muted2); line-height: 1.5; }
.form-actions{ margin-top: 14px; display:flex; gap:8px; }

.tabs{ display:flex; gap:8px; margin-bottom: 10px; }
.tab{
  flex:1;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: var(--muted);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 900;
  cursor:pointer;
}
.tab.active{
  border-color: rgba(168,85,247,.35);
  background: rgba(168,85,247,.12);
  color: #e9d5ff;
}

.group{ margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.group-title{ font-weight: 900; color:#e9d5ff; margin-bottom: 10px; }
.group.danger .group-title{ color:#fda4af; }
.opt-row{ margin: 10px 0; }
.opt{ font-size: 13px; color:#e5e7eb; display:flex; gap:10px; align-items:center; line-height:1.4; }
.opt code{ font-size: 12px; padding: 1px 6px; background: rgba(255,255,255,.08); border-radius: 6px; }

.bottom-nav{
  position: fixed;
  left:0; right:0;
  bottom:0;
  padding: 8px calc(12px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background: rgba(10,10,26,.86);
  border-top: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
  display:flex; gap:8px;
  z-index:30;
}
.nav-btn{
  flex:1;
  border:none;
  border-radius: 14px;
  padding: 10px 8px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--muted);
  font-weight: 900;
  cursor:pointer;
}
.nav-btn.active{
  background: rgba(168,85,247,.14);
  border-color: rgba(168,85,247,.30);
  color:#e9d5ff;
}

.sheet-backdrop{
  position:fixed; inset:0;
  background: rgba(0,0,0,.55);
  z-index:40;
}
.sheet{
  position:fixed;
  left:0; right:0;
  bottom:0;
  max-height: 70vh;
  background: linear-gradient(180deg, rgba(26,26,46,.98), rgba(22,33,62,.98));
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid rgba(255,255,255,.10);
  z-index:41;
  padding-bottom: calc(12px + var(--safe-bottom));
}
.sheet-handle{
  width: 52px; height: 5px;
  background: rgba(255,255,255,.18);
  border-radius:999px;
  margin: 10px auto 0 auto;
}
.sheet-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sheet-title{ font-weight: 900; color:#e9d5ff; }
.sheet-body{ padding: 10px 14px; display:flex; flex-direction:column; gap:8px; overflow:auto; max-height: 58vh; }
.deck-item{
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  cursor:pointer;
}
.deck-item:hover{ background: rgba(255,255,255,.06); }
.deck-name{ font-weight: 900; color:#e9d5ff; font-size: 13px; }
.deck-counts{ font-size: 11px; color: var(--muted2); }

.toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(78px + var(--safe-bottom));
  background: rgba(0,0,0,.75);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  padding: 10px 12px;
  border-radius: 12px;
  z-index: 60;
  font-size: 13px;
  max-width: min(520px, calc(100vw - 24px));
  text-align:center;
}

.empty-state{
  margin: 18px 14px;
  padding: 18px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  text-align:center;
}
.empty-emoji{ font-size: 40px; margin-bottom: 8px; }
.empty-title{ font-weight: 900; font-size: 16px; margin-bottom: 6px; }
.empty-desc{ color: var(--muted2); font-size: 12px; line-height:1.6; }
.empty-actions{ display:flex; gap:8px; margin-top: 12px; justify-content:center; flex-wrap:wrap; }

.wrongtag-box{
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(251,191,36,.08);
  border: 1px solid rgba(251,191,36,.22);
}
.wrongtag-title{
  font-weight: 900;
  font-size: 12px;
  color: #fbbf24;
  margin-bottom: 10px;
}
.wrongtag-chips{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor:pointer;
}
.chip:active{ transform: scale(.99); }
