/* Flash — SM-2 spaced-repetition flashcards
 * Palette: plum + butter-yellow
 * © אופיר ברנס (Ofir Baranes) 2026
 */

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg-1: #1a0a1f;
  --bg-2: #25102d;
  --bg-3: #321538;
  --plum-300: #f0abfc;
  --plum-400: #e879f9;
  --plum-500: #d946ef;
  --plum-600: #c026d3;
  --plum-700: #a21caf;
  --plum-800: #86198f;
  --plum-900: #581c87;
  --gold: #fde047;
  --gold-soft: #facc15;
  --cream: #fef3c7;
  --cream-light: #fffbeb;
  --text-primary: #faf5ff;
  --text-secondary: rgba(250,245,255,0.72);
  --text-muted: rgba(250,245,255,0.42);
  --surface: rgba(250,245,255,0.05);
  --surface-strong: rgba(250,245,255,0.10);
  --border: rgba(240,171,252,0.16);
  --border-strong: rgba(240,171,252,0.28);
  --shadow-glass: 0 30px 60px -25px rgba(26,10,31,0.7);
  --bezier: cubic-bezier(.34,1.56,.64,1);
  --bezier-soft: cubic-bezier(.4,0,.2,1);
}

html, body {
  background: var(--bg-1);
  color: var(--text-primary);
  font-family: 'Heebo', system-ui, sans-serif;
  font-weight: 400;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 700px 800px at 80% -10%, rgba(217,70,239,0.20), transparent 60%),
    radial-gradient(ellipse 500px 600px at -10% 60%, rgba(253,224,71,0.10), transparent 65%),
    radial-gradient(ellipse 800px 1000px at 50% 110%, rgba(134,25,143,0.22), transparent 70%),
    linear-gradient(180deg, #1a0a1f 0%, #25102d 60%, #321538 110%);
  background-attachment: fixed;
  position: relative;
  padding-bottom: 60px;
}

.ambient-bg {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb-blur {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.45;
}
.orb-blur.o1 { width: 420px; height: 420px; top: -120px; right: -120px; background: radial-gradient(circle, #c026d3 0%, transparent 70%); animation: drift1 26s ease-in-out infinite; }
.orb-blur.o2 { width: 340px; height: 340px; bottom: 5%; left: -100px; background: radial-gradient(circle, #fde047 0%, transparent 70%); opacity: 0.22; animation: drift2 32s ease-in-out infinite; }
.orb-blur.o3 { width: 260px; height: 260px; top: 40%; right: 30%; background: radial-gradient(circle, #86198f 0%, transparent 70%); opacity: 0.32; animation: drift3 38s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-30px,40px) scale(1.1); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,-30px) scale(1.08); } }
@keyframes drift3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-25px,-35px) scale(1.12); } }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(26,10,31,0.85) 0%, rgba(26,10,31,0.55) 100%);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--plum-300);
  letter-spacing: -0.01em;
}
.mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--plum-400), var(--plum-800));
  color: var(--cream-light);
  box-shadow: 0 0 18px rgba(217,70,239,0.4);
}
.mark svg { width: 18px; height: 18px; }

.header-actions { display: flex; gap: 8px; }
.icon-btn, .install-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  border-radius: 12px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.2s var(--bezier-soft);
  backdrop-filter: blur(10px);
}
.icon-btn { padding: 7px 9px; font-size: 16px; }
.icon-btn:hover, .install-btn:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.install-btn {
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  border: none;
  color: var(--bg-1);
  font-weight: 600;
}

main {
  position: relative;
  z-index: 1;
  padding: 22px 18px;
  max-width: 880px;
  margin: 0 auto;
}
.hidden { display: none !important; }
.panel { animation: fade-in 0.5s var(--bezier-soft); }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Hero header ===== */
.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 18px;
}
.hero-left { flex: 1; min-width: 0; }
.kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--plum-300);
  margin-bottom: 6px;
}
.hero-title {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: clamp(34px, 7vw, 56px);
  font-weight: 700;
  line-height: 0.95;
  color: var(--cream-light);
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}
.hero-title .ital {
  font-style: italic;
  font-weight: 500;
  color: var(--gold);
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.hm-stat { display: flex; flex-direction: column; }
.hm-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--cream-light);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hm-num.accent { color: var(--gold); }
.hm-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  letter-spacing: 0.05em;
}
.hm-sep { width: 1px; height: 28px; background: var(--border-strong); }

.hero-right { flex-shrink: 0; }
.hero-illust { width: 140px; height: 110px; }
.hero-illust svg { width: 100%; height: 100%; filter: drop-shadow(0 14px 24px rgba(134,25,143,0.4)); }

/* ===== Smart study CTA ===== */
.btn-study-all {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(135deg, var(--plum-700), var(--plum-900));
  border: 1px solid var(--plum-600);
  border-radius: 22px;
  color: var(--cream-light);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s var(--bezier);
  margin-bottom: 24px;
  box-shadow: 0 14px 30px rgba(134,25,143,0.4);
  text-align: right;
}
.btn-study-all:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(134,25,143,0.55);
}
.bsa-icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.18);
  border-radius: 14px;
  flex-shrink: 0;
}
.bsa-icon svg { width: 20px; height: 20px; color: var(--gold); }
.bsa-info { flex: 1; min-width: 0; }
.bsa-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.bsa-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}
.bsa-arrow {
  font-size: 24px;
  opacity: 0.7;
  flex-shrink: 0;
}

/* ===== Section header ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
  padding: 0 4px;
}
.section-title {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--cream-light);
  letter-spacing: -0.015em;
}
.btn-mini-inline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  color: var(--gold);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-mini-inline:hover {
  background: var(--surface-strong);
  border-color: var(--gold);
}

/* ===== Decks grid ===== */
.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.deck-card {
  position: relative;
  padding: 18px;
  background: linear-gradient(140deg, var(--surface-strong) 0%, var(--surface) 100%);
  backdrop-filter: blur(16px) saturate(150%);
  border: 1px solid var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: all 0.3s var(--bezier);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 150px;
  overflow: hidden;
}
.deck-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 22px;
  padding: 1px;
  background: linear-gradient(135deg, var(--dc, var(--plum-500)) 0%, transparent 50%);
  -webkit-mask: linear-gradient(#000,#000) content-box, linear-gradient(#000,#000);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.deck-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glass), 0 0 30px color-mix(in srgb, var(--dc, var(--plum-500)) 25%, transparent);
}
.deck-card:hover::before { opacity: 1; }
.deck-color-tag {
  position: absolute;
  top: 0;
  right: 0;
  width: 64px;
  height: 64px;
  background: var(--dc, var(--plum-500));
  border-radius: 0 22px 0 64px;
  opacity: 0.18;
  pointer-events: none;
}
.deck-name {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--cream-light);
  line-height: 1.15;
  letter-spacing: -0.015em;
  position: relative;
  z-index: 1;
}
.deck-desc {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.deck-stats {
  display: flex;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.deck-stats .due { color: var(--gold); font-weight: 600; }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 24px;
}
.empty-state .icon { font-size: 42px; margin-bottom: 10px; opacity: 0.6; }
.empty-state h3 {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--cream-light);
  margin-bottom: 6px;
}
.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto;
}

/* ===== Deck detail panel ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 18px;
  transition: all 0.2s;
}
.back-btn:hover { background: var(--surface); color: var(--cream-light); }
.back-btn svg { width: 14px; height: 14px; transform: scaleX(-1); }

.deck-hero {
  background: linear-gradient(140deg, var(--surface-strong) 0%, var(--surface) 100%);
  backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  padding: 26px 24px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.deck-hero::before {
  content: '';
  position: absolute;
  top: -2px; right: -2px; bottom: -2px; left: -2px;
  border-radius: 26px;
  padding: 1.5px;
  background: linear-gradient(135deg, var(--dh, var(--plum-500)) 0%, transparent 60%);
  -webkit-mask: linear-gradient(#000,#000) content-box, linear-gradient(#000,#000);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.deck-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.deck-hero-cat {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--dh, var(--plum-300));
  margin-bottom: 4px;
}
.deck-hero-title {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 700;
  color: var(--cream-light);
  line-height: 1;
  letter-spacing: -0.02em;
}
.deck-hero-stats {
  display: flex;
  gap: 22px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.dhs-item { display: flex; flex-direction: column; gap: 3px; }
.dhs-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--cream-light);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.dhs-num.accent { color: var(--gold); }
.dhs-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== Cards list (in deck) ===== */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s var(--bezier-soft);
}
.card-item:hover {
  background: var(--surface-strong);
  border-color: var(--border-strong);
  transform: translateX(-3px);
}
.ci-stage {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 100px;
  flex-shrink: 0;
}
.ci-stage.new { background: rgba(253,224,71,0.18); color: var(--gold); }
.ci-stage.learn { background: rgba(217,70,239,0.18); color: var(--plum-300); }
.ci-stage.due { background: rgba(251,113,133,0.18); color: #fda4af; }
.ci-stage.mastered { background: rgba(134,239,172,0.18); color: #86efac; }
.ci-body { flex: 1; min-width: 0; }
.ci-front {
  font-size: 14px;
  color: var(--cream-light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.ci-back {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ci-when {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-mini {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
  border: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--plum-500), var(--plum-800));
  color: var(--cream-light);
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(217,70,239,0.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(217,70,239,0.5); }
.btn-primary.big {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px;
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  color: var(--bg-1);
  box-shadow: 0 10px 28px rgba(253,224,71,0.4);
}
.btn-primary.big:hover { box-shadow: 0 14px 36px rgba(253,224,71,0.55); }
.btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--cream-light);
}
.btn-secondary:hover { background: var(--surface-strong); }
.btn-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  flex: 0 1 auto;
  padding: 13px 18px;
}
.btn-mini.danger { color: #fda4af; border-color: rgba(253,164,175,0.3); }
.btn-mini.danger:hover { background: rgba(253,164,175,0.1); }

/* ===== Study mode ===== */
.study-mode {
  position: fixed; inset: 0;
  background: linear-gradient(180deg, #25102d 0%, #1a0a1f 100%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.4s var(--bezier-soft);
}
.study-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: rgba(26,10,31,0.6);
  backdrop-filter: blur(20px);
}
.cook-exit {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  color: var(--cream-light);
  cursor: pointer;
  flex-shrink: 0;
}
.cook-exit svg { width: 18px; height: 18px; }
.study-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.study-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(250,245,255,0.08);
  border-radius: 100px;
  overflow: hidden;
}
.spb-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--plum-500));
  width: 0;
  transition: width 0.5s var(--bezier);
  border-radius: 100px;
}
.study-progress-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--cream-light);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.study-deck-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}

.study-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
  perspective: 1200px;
}
.flash-card {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1.6 / 1;
  cursor: pointer;
  transform-style: preserve-3d;
}
.flash-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s var(--bezier);
}
.flash-card.flipped .flash-card-inner {
  transform: rotateY(180deg);
}
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 28px;
  padding: 30px 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: 0 30px 60px -25px rgba(0,0,0,0.7);
}
.card-front {
  background: linear-gradient(140deg, #faf5ff 0%, #f3e8ff 60%, #e9d5ff 100%);
  border: 1px solid rgba(134,25,143,0.2);
}
.card-back {
  background: linear-gradient(140deg, #fffbeb 0%, #fef3c7 60%, #fde68a 100%);
  border: 1px solid rgba(202,138,4,0.25);
  transform: rotateY(180deg);
}
.card-tag {
  position: absolute;
  top: 18px;
  right: 18px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--plum-700);
  background: rgba(134,25,143,0.12);
  padding: 4px 10px;
  border-radius: 100px;
  font-weight: 700;
}
.card-tag.back {
  color: #ca8a04;
  background: rgba(202,138,4,0.15);
}
.card-content {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 700;
  color: var(--bg-1);
  letter-spacing: -0.02em;
  line-height: 1.2;
  word-break: break-word;
  max-height: 80%;
  overflow-y: auto;
}
.card-back .card-content { color: #422006; }
.card-hint {
  position: absolute;
  bottom: 50px;
  left: 0;
  right: 0;
  font-size: 13px;
  color: var(--plum-700);
  opacity: 0.7;
  font-style: italic;
  padding: 0 30px;
}
.card-tap-hint {
  position: absolute;
  bottom: 18px;
  left: 0;
  right: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--plum-700);
  opacity: 0.55;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Study actions */
.study-actions {
  padding: 16px 18px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(26,10,31,0.6);
  backdrop-filter: blur(20px);
}
.btn-study {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--gold), var(--gold-soft));
  border: none;
  border-radius: 18px;
  color: var(--bg-1);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(253,224,71,0.4);
  transition: all 0.25s var(--bezier);
}
.btn-study:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(253,224,71,0.55); }

.grade-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.grade-btn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  padding: 14px 6px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s var(--bezier);
  color: white;
}
.grade-btn:hover { transform: translateY(-2px); }
.grade-btn:active { transform: scale(0.96); }
.grade-btn.again { background: linear-gradient(135deg, #f87171, #b91c1c); box-shadow: 0 6px 16px rgba(220,38,38,0.35); }
.grade-btn.hard { background: linear-gradient(135deg, #fb923c, #c2410c); box-shadow: 0 6px 16px rgba(194,65,12,0.35); }
.grade-btn.good { background: linear-gradient(135deg, #4ade80, #15803d); box-shadow: 0 6px 16px rgba(21,128,61,0.35); }
.grade-btn.easy { background: linear-gradient(135deg, #38bdf8, #0369a1); box-shadow: 0 6px 16px rgba(3,105,161,0.35); }
.g-label { font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
.g-when {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* Study done overlay */
.study-done {
  position: absolute;
  inset: 0;
  background: rgba(26,10,31,0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  animation: fade-in 0.4s var(--bezier-soft);
}
.study-done-card {
  background: linear-gradient(180deg, #2d1638 0%, #1a0a1f 100%);
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  padding: 30px 26px;
  max-width: 380px;
  text-align: center;
  width: 100%;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}
.sd-emoji { font-size: 56px; margin-bottom: 8px; }
.study-done-card h2 {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: -0.015em;
}
.study-done-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 16px;
}
.sd-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px dashed var(--border);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.sd-stat-num {
  font-size: 22px;
  font-weight: 600;
  color: var(--cream-light);
  display: block;
  margin-bottom: 2px;
}

/* ===== Modal ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,5,20,0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: modal-fade 0.25s var(--bezier-soft);
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%;
  max-width: 540px;
  background: linear-gradient(180deg, #2d1638 0%, #1a0a1f 100%);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 20px 22px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  animation: modal-slide 0.4s var(--bezier);
  max-height: 92vh;
  overflow-y: auto;
}
@keyframes modal-slide {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.handle {
  width: 38px; height: 4px;
  background: var(--border-strong);
  border-radius: 4px;
  margin: 0 auto 16px;
}
.modal-card h3 {
  font-family: 'Frank Ruhl Libre', 'Heebo', serif;
  color: var(--cream-light);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
}
.modal-card p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 14px;
}
.mark-big {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--plum-500), var(--plum-800));
  border-radius: 18px;
  color: var(--cream-light);
  margin: 4px auto 14px;
  box-shadow: 0 0 30px rgba(217,70,239,0.4);
}
.mark-big svg { width: 32px; height: 32px; }

.modal-input {
  width: 100%;
  padding: 13px 14px;
  background: rgba(250,245,255,0.05);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--cream-light);
  font-family: 'Heebo', sans-serif;
  font-size: 15px;
  resize: vertical;
  margin-bottom: 14px;
  transition: all 0.2s;
  text-align: right;
  direction: rtl;
  line-height: 1.5;
}
.modal-input:focus {
  outline: none;
  border-color: var(--plum-500);
  background: rgba(250,245,255,0.10);
}
.modal-input::placeholder { color: var(--text-muted); }
textarea.modal-input { min-height: 70px; }

.form-label {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--plum-300);
  margin-bottom: 8px;
}

.color-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
@media (max-width: 480px) { .color-picker { grid-template-columns: repeat(6, 1fr); } }
.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--swatch);
  transition: all 0.2s var(--bezier);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active {
  border-color: var(--cream-light);
  box-shadow: 0 0 14px var(--swatch);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
