/* ══════════════════════════════════════════
   RIFTCARDS — style.css
   ══════════════════════════════════════════ */

/* ── TOKENS ── */
:root {
  --navy:       #0a0f1e;
  --navy-2:     #0e1528;
  --navy-3:     #131c36;
  --navy-4:     #1a2444;
  --navy-5:     #223060;
  --border:     rgba(255,255,255,0.08);
  --border-hi:  rgba(255,255,255,0.16);

  --orange:     #f97316;
  --orange-dim: #c25a0f;
  --orange-glow:rgba(249,115,22,0.25);
  --orange-bg:  rgba(249,115,22,0.10);

  --blue:       #3b82f6;
  --green:      #22c55e;
  --green-bg:   rgba(34,197,94,0.12);
  --red:        #ef4444;
  --red-bg:     rgba(239,68,68,0.12);

  --text:       #e8eeff;
  --text-2:     #9aaacf;
  --text-3:     #5a6a94;

  --font-display: 'Barlow Condensed', sans-serif;
  --font-ui:      'Rajdhani', sans-serif;
  --font-body:    'Barlow', sans-serif;

  --radius-sm:  8px;
  --radius:     14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-lg:  0 20px 60px rgba(0,0,0,0.6);
  --shadow:     0 8px 32px rgba(0,0,0,0.5);
}

/* ── Domain color vars ── */
:root {
  --domain-order:     99,102,241;
  --domain-chaos:     239,68,68;
  --domain-calm:      6,182,212;
  --domain-fury:      249,115,22;
  --domain-mind:      168,85,247;
  --domain-body:      34,197,94;
  --domain-colorless: 148,163,184;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: none; outline: none; }
input, select, textarea { font: inherit; }

/* ── BASE ── */
body {
  font-family: var(--font-body);
  background: var(--navy);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(59,130,246,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 30% at 80% 100%, rgba(249,115,22,0.06) 0%, transparent 60%);
}

/* ── HEADER ── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,15,30,0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 720px; margin: 0 auto;
  padding: 0 16px; height: 54px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 800;
  font-size: 1.35rem; letter-spacing: 0.04em;
  background: transparent; color: var(--text);
  padding: 4px 8px; border-radius: var(--radius-sm);
  transition: opacity 0.15s;
}
.logo:hover { opacity: 0.8; }
.logo-icon   { color: var(--orange); font-size: 1.5rem; line-height: 1; }
.logo-accent { color: var(--orange); }

.session-badge {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-weight: 700; font-size: 0.95rem;
  padding: 4px 12px;
  background: var(--navy-3); border: 1px solid var(--border); border-radius: 99px;
}
.session-badge .sep { color: var(--text-3); }

/* ── MAIN ── */
.app-main { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; }

/* ── UTILITY ── */
.hidden { display: none !important; }
.text-orange { color: var(--orange); }
.mt-sm { margin-top: 10px; }

/* ══════════════════════════════ SETUP PANEL ══════════════════════════════ */
.setup-panel { padding-top: 28px; }
.setup-hero  { margin-bottom: 32px; }
.setup-hero h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  line-height: 1.1; letter-spacing: -0.01em; margin-bottom: 10px;
}
.setup-sub { color: var(--text-2); font-size: 0.95rem; line-height: 1.6; }

.setup-step {
  background: var(--navy-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: 14px;
  overflow: hidden; transition: border-color 0.2s;
  animation: fadeSlideUp 0.3s ease both;
}
.setup-step:nth-child(2) { animation-delay: 0.05s; }
.setup-step:nth-child(3) { animation-delay: 0.1s; }
.setup-step:focus-within { border-color: var(--border-hi); }

.step-label {
  padding: 14px 18px 10px;
  font-family: var(--font-display); font-weight: 800;
  font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3); display: flex; align-items: center; gap: 8px;
}
.step-num { color: var(--orange); font-size: 0.9rem; }
.step-content { padding: 0 18px 18px; }

.filter-section { margin-bottom: 18px; }
.filter-section:last-child { margin-bottom: 0; }
.filter-section > label { display: block; margin-bottom: 8px; }

/* Fields */
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 140px; }
label {
  font-size: 0.82rem; font-family: var(--font-ui); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3);
}

input, .select-wrap select {
  width: 100%; background: var(--navy-4); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); padding: 0 14px;
  height: 46px; font-size: 0.95rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none; appearance: none;
}
input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }

/* Chips */
.chip-group {
  display: flex; flex-wrap: wrap; gap: 8px;
  min-height: 38px; align-items: flex-start; padding-top: 2px;
}
.chip-loading { font-size: 0.85rem; color: var(--text-3); padding: 6px 0; font-style: italic; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 13px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--navy-4);
  font-size: 0.85rem; font-family: var(--font-ui); font-weight: 600;
  color: var(--text-2); cursor: pointer; transition: all 0.15s; user-select: none;
}
.chip:hover   { border-color: var(--orange); color: var(--text); }
.chip.active  { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }
.chip-color-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* Study mode selector */
.mode-group {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.btn-mode {
  padding: 7px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--navy-4);
  font-family: var(--font-ui); font-weight: 700; font-size: 0.88rem;
  color: var(--text-2); transition: all 0.15s; cursor: pointer;
}
.btn-mode:hover  { border-color: var(--orange); color: var(--text); }
.btn-mode.active { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }

/* SR info badge */
.sr-info {
  display: flex; align-items: center; gap: 7px;
  margin-top: 12px; padding: 8px 12px;
  background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.25);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-weight: 700; font-size: 0.88rem; color: var(--green);
}

/* Count display */
.count-display {
  height: 46px; display: flex; align-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 1.6rem;
  color: var(--orange); transition: transform 0.15s;
}
.count-display.bump { animation: countBump 0.25s ease; }
@keyframes countBump {
  0%  { transform: scale(1); }
  50% { transform: scale(1.18); }
  100%{ transform: scale(1); }
}

/* Toggle buttons */
.btn-group { display: flex; gap: 6px; height: 46px; align-items: center; }
.btn-toggle {
  flex: 1; height: 38px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--navy-4);
  color: var(--text-2); font-family: var(--font-ui); font-weight: 700;
  font-size: 0.9rem; transition: all 0.15s;
}
.btn-toggle.active { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }

/* Status message */
.status-msg { min-height: 22px; font-size: 0.88rem; color: var(--text-3); margin-top: 10px; }
.status-msg.error   { color: var(--red); }
.status-msg.success { color: var(--green); }
.status-msg.loading { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border-hi);
  border-top-color: var(--orange); border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Launch row */
.launch-row { display: flex; gap: 10px; margin-top: 18px; }
.launch-row .btn { flex: 1; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; border-radius: var(--radius);
  font-family: var(--font-ui); font-weight: 700; letter-spacing: 0.05em;
  font-size: 1rem; padding: 0 20px; height: 50px;
  transition: all 0.15s; border: 1px solid transparent;
}
.btn-sm   { height: 38px; font-size: 0.88rem; padding: 0 14px; }
.btn-icon { height: 46px; width: 46px; padding: 0; flex-shrink: 0; border-radius: var(--radius); background: var(--navy-4); border: 1px solid var(--border); color: var(--text-2); }
.btn-icon:hover { border-color: var(--orange); color: var(--orange); }
.btn-icon-sm { height: 28px; width: 28px; background: transparent; border-color: transparent; margin-left: auto; }
.btn-icon-sm:hover { background: var(--navy-4); border-color: var(--border); }

.btn-primary { background: linear-gradient(135deg, var(--orange), var(--orange-dim)); color: #fff; box-shadow: 0 4px 20px var(--orange-glow); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 28px var(--orange-glow); }
.btn-primary:disabled { background: var(--navy-5); color: var(--text-3); box-shadow: none; cursor: not-allowed; }

.btn-secondary { background: var(--navy-4); border-color: var(--border-hi); color: var(--text); }
.btn-secondary:hover { border-color: var(--orange); color: var(--orange); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }

.btn-outline { background: transparent; border-color: var(--border-hi); color: var(--text-2); }
.btn-outline:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }
.btn-outline:disabled { opacity: 0.4; cursor: not-allowed; }

/* ══════════════════════════════ STUDY PANEL ══════════════════════════════ */
.study-panel {
  padding-top: 0; display: flex; flex-direction: column; gap: 0;
  min-height: calc(100dvh - 54px);
}

.progress-bar-wrap { height: 3px; background: var(--navy-4); overflow: hidden; margin: 0 -16px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--orange), #fbbf24); width: 0%; transition: width 0.35s ease; }

.study-topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 0;
}
.study-topbar-right { display: flex; align-items: center; gap: 8px; }
.study-counter { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; color: var(--text-2); }
.score-mini { display: flex; gap: 8px; font-family: var(--font-ui); font-weight: 700; font-size: 0.9rem; }
.score-ok { color: var(--green); }
.score-ko { color: var(--red); }

/* Mode badge */
.mode-badge {
  text-align: center; padding: 4px 0 6px;
  font-family: var(--font-ui); font-weight: 700; font-size: 0.78rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3);
}

/* Shortcuts button */
.btn-shortcuts {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--border-hi); background: var(--navy-4);
  color: var(--text-2); font-family: var(--font-ui); font-weight: 700; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.btn-shortcuts:hover { border-color: var(--orange); color: var(--orange); }

/* Card scene */
.card-scene {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 8px 0 12px; justify-content: center;
}

.flashcard {
  width: min(100%, calc((100dvh - 270px) * 63 / 88));
  max-width: 340px;
  aspect-ratio: 63 / 88;
  perspective: 1400px; cursor: pointer;
}
.card-inner {
  width: 100%; height: 100%; position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-xl);
}
.flashcard.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; border-radius: var(--radius-xl);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  overflow: hidden; box-shadow: var(--shadow-lg);
}

/* ── CARD FRONT — domain-colored ── */
.card-front {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 24px 22px 16px; position: relative;
  /* Default (no domain) */
  background: linear-gradient(145deg, var(--navy-4) 0%, var(--navy-3) 60%, var(--navy-2) 100%);
  border: 1px solid rgba(255,255,255,0.1);
}
/* Domain-specific gradients + border tints */
.flashcard[data-domain="order"]     .card-front { background: linear-gradient(145deg, rgba(var(--domain-order),0.18) 0%, var(--navy-3) 55%, var(--navy-2) 100%); border-color: rgba(var(--domain-order),0.3); }
.flashcard[data-domain="chaos"]     .card-front { background: linear-gradient(145deg, rgba(var(--domain-chaos),0.18) 0%, var(--navy-3) 55%, var(--navy-2) 100%); border-color: rgba(var(--domain-chaos),0.3); }
.flashcard[data-domain="calm"]      .card-front { background: linear-gradient(145deg, rgba(var(--domain-calm),0.16) 0%, var(--navy-3) 55%, var(--navy-2) 100%); border-color: rgba(var(--domain-calm),0.3); }
.flashcard[data-domain="fury"]      .card-front { background: linear-gradient(145deg, rgba(var(--domain-fury),0.18) 0%, var(--navy-3) 55%, var(--navy-2) 100%); border-color: rgba(var(--domain-fury),0.3); }
.flashcard[data-domain="mind"]      .card-front { background: linear-gradient(145deg, rgba(var(--domain-mind),0.18) 0%, var(--navy-3) 55%, var(--navy-2) 100%); border-color: rgba(var(--domain-mind),0.3); }
.flashcard[data-domain="body"]      .card-front { background: linear-gradient(145deg, rgba(var(--domain-body),0.18) 0%, var(--navy-3) 55%, var(--navy-2) 100%); border-color: rgba(var(--domain-body),0.3); }
.flashcard[data-domain="colorless"] .card-front { background: linear-gradient(145deg, rgba(var(--domain-colorless),0.10) 0%, var(--navy-3) 55%, var(--navy-2) 100%); border-color: rgba(var(--domain-colorless),0.2); }

.card-front::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 70% 40% at 50% 0%, rgba(249,115,22,0.06) 0%, transparent 60%);
  border-radius: inherit;
}
.card-front-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; flex: 1; justify-content: center; text-align: center;
}
.front-type-badge {
  display: inline-flex; align-self: center;
  padding: 5px 16px; border-radius: 99px;
  border: 1px solid var(--orange); background: var(--orange-bg); color: var(--orange);
  font-family: var(--font-display); font-weight: 800;
  font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase;
}
/* Normal mode: name */
.front-name {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 2rem); letter-spacing: 0.02em;
  color: var(--text); line-height: 1.2; padding: 0 8px;
}
/* Inverse mode: stats */
.front-stats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.stat-pill {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 14px; background: var(--navy-4);
  border: 1px solid var(--border); border-radius: var(--radius-sm); min-width: 58px;
}
.stat-pill-label { font-size: 0.68rem; font-family: var(--font-ui); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.stat-pill-value { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; color: var(--text); }
.front-text { color: var(--text-2); font-size: 0.85rem; line-height: 1.5; font-style: italic; max-width: 90%; }
.front-keywords { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.keyword-tag {
  padding: 3px 10px; border-radius: 99px;
  background: var(--navy-5); border: 1px solid var(--border);
  font-size: 0.78rem; font-family: var(--font-ui); font-weight: 600;
  color: var(--blue); letter-spacing: 0.04em;
}

.card-flip-hint { text-align: center; font-size: 0.78rem; color: var(--text-3); padding-top: 8px; }

/* BACK */
.card-back { transform: rotateY(180deg); background: var(--navy-2); display: flex; flex-direction: column; }
.back-image-wrap { flex: 1; overflow: hidden; position: relative; background: var(--navy); }
.back-image-wrap img { width: 100%; height: 100%; object-fit: contain; }
.back-img-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 0.9rem; }
.back-info { padding: 12px 18px 14px; border-top: 1px solid var(--border); background: var(--navy-2); text-align: center; }
.back-name { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.1rem, 4vw, 1.6rem); color: var(--text); margin-bottom: 3px; }
.back-set-label { font-size: 0.75rem; font-family: var(--font-ui); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }

/* QCM mode: hide back-info so name not visible */
.study-panel.mode-multiple .back-info { display: none; }

/* Zoom button on card back */
.zoom-btn {
  position: absolute; bottom: 10px; right: 10px;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: rgba(10,15,30,0.7); border: 1px solid var(--border-hi);
  color: var(--text-2); display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; opacity: 0.7;
}
.zoom-btn:hover { opacity: 1; border-color: var(--orange); color: var(--orange); }

/* Eval flash overlay */
.eval-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  opacity: 0; border-radius: 0;
}
.eval-flash.flash-correct { animation: flashCorrect 0.5s ease forwards; }
.eval-flash.flash-wrong   { animation: flashWrong   0.5s ease forwards; }
@keyframes flashCorrect {
  0%   { opacity: 0.35; background: var(--green); }
  100% { opacity: 0; background: var(--green); }
}
@keyframes flashWrong {
  0%   { opacity: 0.35; background: var(--red); }
  100% { opacity: 0; background: var(--red); }
}

/* Swipe hint */
.swipe-hint { display: flex; justify-content: space-between; width: 100%; max-width: 400px; padding: 8px 4px 0; font-size: 0.78rem; color: var(--text-3); }

/* Eval row */
.eval-row { display: flex; gap: 10px; padding: 4px 0 8px; max-width: 500px; margin: 0 auto; width: 100%; }
.btn-eval { flex: 1; height: 52px; border-radius: var(--radius); font-family: var(--font-ui); font-weight: 700; font-size: 0.95rem; border: 1px solid transparent; gap: 8px; }
.btn-wrong   { background: var(--red-bg);   border-color: rgba(239,68,68,0.3);  color: var(--red); }
.btn-wrong:hover   { background: rgba(239,68,68,0.2); }
.btn-correct { background: var(--green-bg); border-color: rgba(34,197,94,0.3);  color: var(--green); }
.btn-correct:hover { background: rgba(34,197,94,0.2); }

/* QCM row */
.qcm-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; padding: 8px 0 4px;
  width: 100%; max-width: 500px;
}
.btn-qcm {
  padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-hi); background: var(--navy-3);
  color: var(--text); font-family: var(--font-ui); font-weight: 700;
  font-size: 0.9rem; text-align: center; cursor: pointer;
  transition: all 0.15s; line-height: 1.3;
}
.btn-qcm:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); background: var(--orange-bg); }
.btn-qcm.correct { background: var(--green-bg);  border-color: rgba(34,197,94,0.5);  color: var(--green); }
.btn-qcm.wrong   { background: var(--red-bg);    border-color: rgba(239,68,68,0.5);   color: var(--red); }
.btn-qcm:disabled { opacity: 0.6; cursor: default; }

/* Nav row */
.nav-row { display: flex; gap: 8px; padding-bottom: 16px; align-items: center; justify-content: center; max-width: 500px; margin: 0 auto; width: 100%; }
.btn-nav { height: 48px; min-width: 48px; background: var(--navy-3); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); transition: all 0.15s; }
.btn-nav:hover { border-color: var(--border-hi); color: var(--text); }
.btn-flip { flex: 1; max-width: 160px; font-family: var(--font-ui); font-weight: 700; font-size: 0.95rem; color: var(--orange); border-color: rgba(249,115,22,0.3); background: var(--orange-bg); }
.btn-flip:hover { background: rgba(249,115,22,0.2); border-color: var(--orange); }
.btn-random { font-size: 1.1rem; }

/* ══════════════════════════════ RESULTS PANEL ══════════════════════════════ */
.results-panel { padding-top: 48px; }
.results-inner { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }

/* Circular gauge */
.results-gauge-wrap { position: relative; width: 140px; height: 140px; }
.gauge-svg { width: 100%; height: 100%; }
#gaugeCircle { transition: stroke-dashoffset 1s cubic-bezier(0.4,0,0.2,1); }
.gauge-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.gauge-pct { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; color: var(--orange); line-height: 1; }
.gauge-sub  { font-size: 0.72rem; font-family: var(--font-ui); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-top: 2px; }

.results-title { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.8rem, 6vw, 2.4rem); }
.results-stats { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.result-stat { background: var(--navy-3); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 24px; min-width: 90px; }
.result-stat-ok { border-color: rgba(34,197,94,0.3); background: var(--green-bg); }
.result-stat-ko { border-color: rgba(239,68,68,0.3); background: var(--red-bg); }
.rs-value { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; line-height: 1; margin-bottom: 4px; }
.result-stat-ok .rs-value { color: var(--green); }
.result-stat-ko .rs-value { color: var(--red); }
.rs-label { font-size: 0.82rem; font-family: var(--font-ui); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.result-msg { font-size: 1.05rem; color: var(--text-2); line-height: 1.6; max-width: 320px; }

/* Missed cards list */
.missed-section { width: 100%; max-width: 440px; }
.missed-title { font-family: var(--font-ui); font-weight: 700; font-size: 0.82rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.missed-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.missed-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--navy-3); border: 1px solid var(--border);
  font-family: var(--font-ui); font-size: 0.9rem;
}
.missed-item-type { font-size: 0.72rem; color: var(--text-3); flex-shrink: 0; }
.missed-item-name { flex: 1; font-weight: 700; color: var(--text); text-align: left; }
.missed-item-count { font-size: 0.78rem; color: var(--red); font-weight: 700; flex-shrink: 0; }

.results-actions { display: flex; gap: 10px; width: 100%; max-width: 360px; }
.results-actions .btn { flex: 1; }

/* ══════════════════════════════ MODAL BASE ══════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5,8,20,0.85); backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.modal-panel {
  width: 100%; max-width: 700px; max-height: 90dvh;
  background: var(--navy-2); border: 1px solid var(--border-hi);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-lg); animation: slideUp 0.25s ease;
}
.modal-sm { max-width: 480px; }
.modal-header { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title  { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; flex: 1; }
.modal-count  { font-family: var(--font-ui); font-weight: 700; font-size: 0.9rem; color: var(--orange); white-space: nowrap; }
.modal-search-bar { padding: 12px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-search-bar input { width: 100%; height: 42px; background: var(--navy-4); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 0 14px; font-size: 0.95rem; outline: none; }
.modal-search-bar input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }
.modal-footer { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.modal-footer .btn-primary { flex: 1; min-width: 140px; }

/* Card browser grid */
.card-browser-grid { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.browser-empty { text-align: center; color: var(--text-3); padding: 40px 0; font-style: italic; }
.browser-card {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--navy-3); cursor: pointer; transition: all 0.15s; position: relative;
}
.browser-card:hover    { border-color: var(--border-hi); background: var(--navy-4); }
.browser-card.selected { border-color: var(--orange); background: var(--orange-bg); }
.browser-thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 5px; flex-shrink: 0; background: var(--navy-5); }
.browser-thumb-empty { width: 40px; height: 56px; border-radius: 5px; flex-shrink: 0; background: var(--navy-5); border: 1px solid var(--border); }
.browser-card-info { flex: 1; min-width: 0; }
.browser-card-name { font-family: var(--font-ui); font-weight: 700; font-size: 0.92rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.browser-card-meta { font-size: 0.76rem; color: var(--text-3); }
.browser-check {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: transparent; transition: all 0.15s;
}
.browser-card.selected .browser-check { background: var(--orange); border-color: var(--orange); color: #fff; }

/* ══════════════════════════════ OVERLAY DARK (zoom, shortcuts) ══════════════════════════════ */
.overlay-dark {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(5,8,20,0.92); backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Image zoom */
.zoom-img {
  max-width: min(90vw, 480px); max-height: 85dvh;
  object-fit: contain; border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.8);
  animation: zoomIn 0.25s ease;
}
@keyframes zoomIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.zoom-close {
  position: fixed; top: 20px; right: 20px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--navy-3); border: 1px solid var(--border-hi);
  color: var(--text-2); display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.zoom-close:hover { border-color: var(--orange); color: var(--orange); }

/* Keyboard shortcuts */
.shortcuts-panel {
  width: 100%; max-width: 420px;
  background: var(--navy-2); border: 1px solid var(--border-hi);
  border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg);
  animation: zoomIn 0.2s ease;
}
.shortcuts-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.shortcuts-title { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; }
.shortcuts-grid { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.shortcut-row { display: flex; align-items: center; gap: 14px; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 68px; padding: 4px 10px;
  background: var(--navy-4); border: 1px solid var(--border-hi);
  border-radius: 6px; border-bottom-width: 2px;
  font-family: var(--font-ui); font-weight: 700; font-size: 0.82rem;
  color: var(--orange); letter-spacing: 0.04em; flex-shrink: 0;
}
.shortcut-row span { font-size: 0.9rem; color: var(--text-2); }

/* Import modal */
.import-content { padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.import-hint { font-size: 0.9rem; color: var(--text-2); }
.import-textarea {
  width: 100%; height: 120px; background: var(--navy-4);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); padding: 12px; font-size: 0.82rem;
  resize: vertical; outline: none; line-height: 1.5;
}
.import-textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-glow); }
.import-error { padding: 8px 12px; background: var(--red-bg); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--red); }

/* ══════════════════════════════ ANIMATIONS ══════════════════════════════ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.card-enter { animation: cardEnter 0.3s ease; }
@keyframes cardEnter {
  from { opacity: 0.5; transform: scale(0.97); }
  to   { opacity: 1;   transform: scale(1); }
}

/* ══════════════════════════════ DESKTOP ══════════════════════════════ */
@media (min-width: 480px) {
  .app-main { padding: 0 24px 48px; }
  .flashcard { max-width: 360px; }
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-panel { border-radius: var(--radius-xl); max-height: 85dvh; }
}
@media (min-width: 640px) {
  .setup-hero h1 { font-size: 2.6rem; }
  .flashcard {
    width: min(100%, calc((100dvh - 270px) * 63 / 88));
    max-width: 400px;
  }
}
@media (min-width: 900px) {
  .app-main { max-width: 800px; }
  .header-inner { max-width: 800px; }
  .flashcard { width: min(100%, calc((100dvh - 280px) * 63 / 88)); max-width: 440px; }
}
@media (min-width: 1200px) {
  .app-main { max-width: 900px; }
  .header-inner { max-width: 900px; }
  .flashcard { width: min(100%, calc((100dvh - 280px) * 63 / 88)); max-width: 480px; }
}
