/* matura.lol — tryb nauki (discovery widget + bento + studio). Theme-aware. */

:root {
  --learn-surface: #1b1f26;
  --learn-surface-2: #232830;
  --learn-border: #2c313a;
  --learn-fire: linear-gradient(135deg, #ff8a3d, #ff3d2e);
  --learn-good: #2e9e63;
  --learn-warn: #c98a1a;
  --learn-bad: #c9503f;
  --learn-blue: #3b82f6;
}

[data-theme="light"] {
  --learn-surface: #f6f5f1;
  --learn-surface-2: #ffffff;
  --learn-border: #e6e3db;
  --learn-good: #1f8a52;
  --learn-warn: #a86f0d;
  --learn-bad: #c0392b;
}

/* ---------- hero cue: fire-only pill, expands to show the label + a × ---------- */
.learn-cue {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-top: 20px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font-size: 14px;
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, box-shadow .2s ease;
}
.learn-cue:hover,
.learn-cue:focus-within,
.learn-cue.open {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent), var(--shadow);
}
.learn-cue-main {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: gap .3s cubic-bezier(.2, .8, .3, 1);
}
.learn-cue:hover .learn-cue-main,
.learn-cue:focus-within .learn-cue-main,
.learn-cue.open .learn-cue-main { gap: 9px; }

/* the separate, rounded × inside the pill, opposite the flame; it collapses
   by width (never display:none) so the whole pill retracts in one motion */
.learn-cue-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 0;
  height: 26px;
  margin-left: 0;
  padding: 0;
  border: 0 solid var(--line);
  border-radius: 50%;
  background: var(--soft);
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: width .3s cubic-bezier(.2, .8, .3, 1), margin-left .3s cubic-bezier(.2, .8, .3, 1),
              opacity .22s ease, border-width .3s ease, color .15s ease, transform .18s ease;
}
/* 12px in a 24px content box => exact 6px on each side (no subpixel shift) */
.learn-cue-x svg { width: 12px; height: 12px; display: block; }
.learn-cue:hover .learn-cue-x,
.learn-cue:focus-within .learn-cue-x,
.learn-cue.open .learn-cue-x { width: 26px; margin-left: 8px; opacity: 1; border-width: 1px; }
.learn-cue-x:hover {
  color: var(--fg);
  border-color: var(--accent);
  background: var(--card);
  transform: translateY(-1px);
}
/* after the second click the pill retracts even while still hovered */
.learn-cue.retracted,
.learn-cue.retracted:hover,
.learn-cue.retracted:focus-within {
  transform: none;
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.learn-cue.retracted .learn-cue-main,
.learn-cue.retracted:hover .learn-cue-main { gap: 0; }
.learn-cue.retracted .learn-cue-label,
.learn-cue.retracted:hover .learn-cue-label { max-width: 0; opacity: 0; }
.learn-cue.retracted .learn-cue-x,
.learn-cue.retracted:hover .learn-cue-x { width: 0; margin-left: 0; opacity: 0; border-width: 0; }
.learn-off { display: none !important; }
.learn-cue-fire {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 20px;
  height: 26px;
  transform-origin: 50% 92%;
  animation: flame-flicker 1.9s ease-in-out infinite;
}
.learn-cue-flame { width: 100%; height: 100%; display: block; overflow: visible; }
.learn-cue-flame .f-outer { fill: #ff4c1f; }
.learn-cue-flame .f-mid { fill: #ff9c45; }
.learn-cue-flame .f-inner { fill: #ffdd56; }
.learn-cue-flame .f-core { fill: #fcfbcc; }
.learn-cue-flame .f-outer,
.learn-cue-flame .f-mid,
.learn-cue-flame .f-inner {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
/* flicker timings mirror the source flame: 3 layered pulses 0.33 / 0.5 / 1 s */
.learn-cue-flame .f-outer { animation: flame-pulse-a .333s linear infinite; }
.learn-cue-flame .f-mid { animation: flame-pulse-b .5s linear infinite; }
.learn-cue-flame .f-inner { animation: flame-pulse-c 1s linear infinite; }
@keyframes flame-pulse-a { 0%, 100% { transform: scale(1); } 50% { transform: scale(.8); } }
@keyframes flame-pulse-b { 0%, 100% { transform: scale(1); } 50% { transform: scale(.9); } }
@keyframes flame-pulse-c { 0%, 100% { transform: scale(1); } 50% { transform: scale(.92); } }
.learn-cue-fire::before,
.learn-cue-fire::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, #fcfbcc, #ffdd56 55%, rgba(255, 76, 31, 0) 78%);
  opacity: 0;
  pointer-events: none;
}
.learn-cue-fire::after {
  left: 62%;
  bottom: 4px;
  width: 5px;
  height: 5px;
  animation: speck-a 1s linear infinite;
}
.learn-cue-fire::before {
  left: 40%;
  bottom: 2px;
  width: 4px;
  height: 4px;
  animation: speck-b 1s linear infinite;
}
.learn-cue-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width .3s cubic-bezier(.2, .8, .3, 1), opacity .22s ease;
}
.learn-cue:hover .learn-cue-label,
.learn-cue:focus-within .learn-cue-label,
.learn-cue.open .learn-cue-label { max-width: 180px; opacity: 1; }

@keyframes flame-flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); filter: drop-shadow(0 0 6px rgba(255, 76, 31, .55)); }
  25% { transform: scale(1.08, 1.14) rotate(2deg); filter: drop-shadow(0 0 10px rgba(255, 156, 69, .85)); }
  50% { transform: scale(.96, 1.05) rotate(-1deg); filter: drop-shadow(0 0 7px rgba(255, 76, 31, .6)); }
  75% { transform: scale(1.1, 1) rotate(1.5deg); filter: drop-shadow(0 0 12px rgba(255, 221, 86, .8)); }
}
@keyframes speck-a {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0); }
  18% { opacity: 1; }
  33% { opacity: 1; transform: translate(-50%, -9px) scale(.8); }
  100% { opacity: 0; transform: translate(-50%, -20px) scale(0); }
}
@keyframes speck-b {
  0%, 33% { opacity: 0; transform: translate(-50%, 0) scale(0); }
  45% { opacity: 1; }
  54% { opacity: 1; transform: translate(-50%, -7px) scale(.3); }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(0); }
}
/* Touch kept identical to pointer: the pill expands via .open (discover shown)
   and collapses via .retracted, so a second tap retracts it the same way. */
@media (prefers-reduced-motion: reduce) {
  .learn-cue-fire, .learn-cue-fire::before, .learn-cue-fire::after,
  .learn-cue-flame .f-outer, .learn-cue-flame .f-mid, .learn-cue-flame .f-inner { animation: none !important; }
  .learn-glow::before { animation: none !important; }
}

/* topbar "Nauka" pill — matches the topbar, not a raw browser button */
.topbar-learn {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--fg);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, color .14s ease;
}
.topbar-learn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--accent);
  background: var(--card);
}
.topbar-learn:active { transform: translateY(0) scale(.97); }

/* ---------- discover section ---------- */
.discover { padding: 6px 20px 84px; }
.discover-inner { max-width: 1040px; margin: 0 auto; }
.discover.reveal { animation: discover-drop .28s cubic-bezier(.2, .8, .3, 1) both; }
.discover.closing { animation: discover-up .28s cubic-bezier(.4, 0, .6, 1) forwards; }
.discover.reveal .bento-card { animation: discover-drop .3s cubic-bezier(.2, .8, .3, 1) both; }
.discover.reveal .bento-card:nth-child(1) { animation-delay: .04s; }
.discover.reveal .bento-card:nth-child(2) { animation-delay: .09s; }
.discover.reveal .bento-card:nth-child(3) { animation-delay: .14s; }
@keyframes discover-drop {
  from { opacity: 0; transform: translateY(-22px); }
  to { opacity: 1; transform: none; }
}
@keyframes discover-up {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-24px); }
}

.learn-widget {
  position: relative;
  z-index: 0;
  background: var(--learn-surface);
  border: 1px solid var(--learn-border);
  border-radius: 26px;
  padding: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* divider belongs to the panel grid (starts below the header) ... */
.learn-widget-grid::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 0;
  bottom: -6px;
  width: 1px;
  background: var(--learn-border);
  pointer-events: none;
}
/* Hard clipping container for the burn: it can never cross the divider. */
.learn-glow {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 0;
  right: -6px;
  bottom: -6px;
  overflow: hidden;
  pointer-events: none;
}
/* Oversized circular glow; .learn-glow clips it to the right column, so the
   only part the user ever sees is the right slice of a big soft flame. */
.learn-glow::before {
  content: "";
  position: absolute;
  left: -35%;
  right: -35%;
  bottom: -105%;
  height: 190%;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(255, 221, 86, .48), rgba(255, 156, 69, .24) 38%,
    rgba(255, 76, 31, .13) 62%, transparent 82%);
  transform-origin: 50% 100%;
  animation: fire-breathe 2.8s ease-in-out infinite;
}
.learn-widget-head { text-align: center; padding: 32px 24px 18px; }
.learn-widget-title {
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 600;
  letter-spacing: -.4px;
  margin: 8px 0 6px;
}
.learn-widget-sub { color: var(--muted); font-size: 14px; margin: 0; }
.learn-widget-grid { position: relative; display: grid; grid-template-columns: 1fr 1fr; }
.learn-panel { padding: 24px 28px 30px; }
.learn-panel + .learn-panel { border-left: 0; }
.learn-panel h3 { font-size: 20px; margin: 0 0 10px; font-weight: 600; }
.learn-panel p { color: var(--muted); font-size: 14px; margin: 0 0 16px; line-height: 1.55; }
.learn-panel > .btn { display: inline-block; }

.learn-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}

@keyframes fire-breathe {
  0%, 100% { transform: scaleY(1) scaleX(1); opacity: .82; }
  25% { transform: scaleY(1.16) scaleX(.98); opacity: 1; }
  50% { transform: scaleY(1.03) scaleX(1.01); opacity: .88; }
  75% { transform: scaleY(1.2) scaleX(.97); opacity: 1; }
}

.learn-field {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.learn-combo { position: relative; }
.learn-combo input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--learn-border);
  background: var(--learn-surface-2);
  color: var(--fg);
  font-size: 15px;
  outline: none;
}
.learn-combo input:focus { border-color: var(--accent); }
.learn-combo-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 6;
  max-height: 250px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.learn-combo-opt {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.learn-combo-opt:hover,
.learn-combo-opt[aria-selected="true"] { background: var(--soft); }
.learn-combo-count { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.learn-control { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.learn-note { color: var(--muted); font-size: 12px; }

/* ---------- chips ---------- */
.discover-heading {
  text-align: center;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 600;
  letter-spacing: -.4px;
  margin: 58px 0 28px;
}

/* ---------- bento ---------- */
.bento { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.bento-card {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 30px 22px;
  border-radius: 22px;
  border: 1px solid var(--learn-border);
  background: var(--learn-surface);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .14s ease, border-color .14s ease;
}
.bento-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.bento-emoji { font-size: 46px; line-height: 1; }
.bento-title { font-size: 20px; font-weight: 600; }
.bento-text { color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 34ch; }
.bento-label {
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
}
.bento-fire .bento-emoji { filter: drop-shadow(0 8px 16px rgba(255, 106, 43, .45)); }

/* ---------- bento hover candy ---------- */
.bento-card { position: relative; }
.bento-card .bento-emoji { transition: transform .2s ease, filter .3s ease; }
.bento-card:hover .bento-emoji,
.bento-card:focus-visible .bento-emoji { transform: scale(1.07); }
.bento-fire:hover .bento-emoji { filter: drop-shadow(0 8px 22px rgba(255, 106, 43, .7)); }

.bento-particle {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  will-change: transform, opacity;
  transform: translate(-50%, -50%);
}
.bento-particle.fire { animation: ember-rise var(--dur, 1.6s) ease-out var(--delay, 0s) both; }
.bento-particle.fire.ember {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe08a, #ff7a18 60%, transparent 72%);
  box-shadow: 0 0 8px rgba(255, 122, 24, .9);
}
.bento-particle.brain { animation: brain-pop var(--dur, 1.3s) cubic-bezier(.2, .8, .3, 1) var(--delay, 0s) both; }

@keyframes ember-rise {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--rise, -70px))) scale(1.15); opacity: 0; }
}
@keyframes brain-pop {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  10% { opacity: 1; }
  30% { transform: translate(calc(-50% + var(--dx, 0px) * .5), calc(-50% + var(--up, -18px))) scale(1); }
  46% { transform: translate(calc(-50% + var(--dx, 0px) * .9), calc(-50% + var(--ground, 46px))) scale(.96); }
  56% { transform: translate(calc(-50% + var(--dx, 0px) * .96), calc(-50% + var(--ground, 46px) - 28px)) scale(1); }
  66% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--ground, 46px))) scale(.94); }
  74% { transform: translate(calc(-50% + var(--dx, 0px) * 1.03), calc(-50% + var(--ground, 46px) - 15px)) scale(1); }
  82% { transform: translate(calc(-50% + var(--dx, 0px) * 1.05), calc(-50% + var(--ground, 46px))) scale(.93); }
  88% { transform: translate(calc(-50% + var(--dx, 0px) * 1.06), calc(-50% + var(--ground, 46px) - 7px)) scale(1); }
  94% { transform: translate(calc(-50% + var(--dx, 0px) * 1.07), calc(-50% + var(--ground, 46px))) scale(.95); }
  100% { transform: translate(calc(-50% + var(--dx, 0px) * 1.08), calc(-50% + var(--ground, 46px))) scale(.9); opacity: 0; }
}
.bento-card[data-tool="interleave"]:hover .bento-emoji,
.bento-card[data-tool="interleave"]:focus-visible .bento-emoji {
  animation: zap .55s ease;
}
@keyframes zap {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 214, 102, 0)); }
  25% { transform: scale(1.5); filter: drop-shadow(0 0 12px rgba(255, 214, 102, .95)); }
  55% { transform: scale(.82); }
  75% { transform: scale(1.12); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 214, 102, 0)); }
}

@media (prefers-reduced-motion: reduce) {
  .bento-particle,
  .pomo-emoji,
  .bento-card:hover .bento-emoji,
  .bento-card[data-tool="interleave"]:hover .bento-emoji { animation: none !important; }
  .ring-fg { transition: stroke .4s ease; }
}

.learn-disclaimer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  max-width: 72ch;
  margin: 28px auto 0;
  line-height: 1.6;
}

/* ---------- session history (game-slot menu) ---------- */
.history-cta { display: flex; justify-content: center; margin-top: 26px; }
.history-searchwrap { padding: 14px 16px 2px; }
#history-search {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
#history-search::placeholder { color: var(--muted); }
#history-search:focus {
  border-color: var(--accent);
  background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.history-head { text-align: center; margin-bottom: 18px; }
.history-head h3 { font-size: 20px; margin: 0 0 10px; font-weight: 600; }
.history-summary { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.history-chart { margin-top: 16px; }
.history-chart-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 5px;
}
.hc-barchart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  min-height: 92px;
  padding: 6px 4px 0;
}
.hc-bar { display: flex; flex-direction: column; align-items: center; width: 34px; }
.hc-bar-val { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.hc-bar-col {
  width: 22px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent), #7fb0ff);
  min-height: 4px;
}
.hc-bar-label { font-size: 14px; line-height: 1; margin-top: 4px; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 16px; }
.history-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--learn-border);
  background: var(--learn-surface);
  box-shadow: var(--shadow);
  transition: transform .14s ease, border-color .14s ease;
}
.history-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.hc-top { display: flex; align-items: center; gap: 8px; }
.hc-emoji { font-size: 20px; line-height: 1; }
.hc-mode {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}
.hc-date { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.hc-term { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-body { display: flex; align-items: center; gap: 14px; }
.hc-donut { width: 64px; height: 64px; flex: 0 0 auto; }
.hc-donut-text { font-size: 15px; font-weight: 700; fill: var(--fg); }
.hc-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; flex: 1; }
.hc-stats div { display: flex; flex-direction: column; }
.hc-stats b { font-size: 16px; }
.hc-stats small { color: var(--muted); font-size: 11px; }
.hc-spark { width: 100%; height: 36px; display: block; }
.hc-resume { text-align: center; }
.history-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 0; }

/* ---------- HIG ergonomics: press states + touch hit targets ---------- */
.learn-subj:active,
.learn-combo-opt:active,
.hc-resume:active,
.pomo-btns button:active { transform: scale(.97); }
.history-card:active { transform: translateY(-1px) scale(.995); }
.learn-close:active { opacity: .8; }

@media (pointer: coarse) {
  .learn-close,
  .learn-cue-x,
  .pomo-btns button { min-width: 44px; min-height: 44px; }
  .learn-subj,
  .learn-combo-opt,
  .learn-gbtn,
  .hc-resume { min-height: 44px; }
}

/* ---------- studio ---------- */
.learn-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, 4vh) 14px;
  background: rgba(4, 6, 10, .62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overflow-y: auto;
  opacity: 0;
  transition: opacity .18s ease;
}
.learn-overlay.open { opacity: 1; }
.learn-overlay[hidden] { display: none; }
.learn-dialog {
  width: min(740px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .5);
  overflow: hidden;
  transform: translateY(14px) scale(.985);
  opacity: 0;
  transition: transform .22s cubic-bezier(.2, .8, .3, 1), opacity .22s ease;
}
.learn-overlay.open .learn-dialog { transform: none; opacity: 1; }
.learn-dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.learn-dialog-title { font-size: 16px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
.learn-dialog-title .learn-method { font-size: 12px; color: var(--muted); font-weight: 400; }
.learn-head-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.learn-close {
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--fg);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.learn-close:hover { border-color: var(--accent); }

.learn-progressline { height: 6px; background: var(--soft); }
.learn-progressline span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7fb0ff); }

.learn-stats { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--soft); }
.learn-stat {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}
.learn-stat b { color: var(--fg); font-weight: 600; }
.learn-streak { display: inline-flex; align-items: center; gap: 4px; line-height: 1; color: #ff8a3d; border-color: rgba(255, 106, 43, .4); }

/* level: number in a pie ring + current level name */
.lvl { display: inline-flex; align-items: center; gap: 8px; }
.lvl-ring { position: relative; width: 36px; height: 36px; flex: 0 0 auto; }
.lvl-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.lvl-ring circle { fill: none; stroke-width: 4; }
.lvl-bg { stroke: var(--line); }
.lvl-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.lvl-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
}
.lvl-name { display: flex; flex-direction: column; line-height: 1.15; font-size: 12px; color: var(--fg); }
.lvl-name small { color: var(--muted); font-size: 11px; }

.learn-stage { padding: 18px 16px 22px; }
.learn-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.learn-meta .badge { font-size: 11px; }
.learn-prompt { font-size: 17px; line-height: 1.65; overflow-wrap: anywhere; }
.learn-prompt-img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  margin: 0 auto 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
}
.learn-hintline { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.learn-reveal { margin-top: 18px; }
.learn-answer {
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.learn-answer .learn-answer-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.learn-answer-key { color: var(--muted); font-size: 12px; margin: 6px 2px 0; }

.learn-grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.learn-grades.two { grid-template-columns: repeat(2, 1fr); }
.learn-gbtn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  border-radius: 12px;
  padding: 12px 8px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform .1s ease, border-color .1s ease;
}
.learn-gbtn small { color: var(--muted); font-size: 11px; }
.learn-gbtn:hover { transform: translateY(-2px); }
.learn-gbtn.g-again:hover { border-color: var(--learn-bad); }
.learn-gbtn.g-hard:hover { border-color: var(--learn-warn); }
.learn-gbtn.g-good:hover { border-color: var(--learn-good); }
.learn-gbtn.g-easy:hover { border-color: var(--learn-blue); }
.learn-gbtn.g-yes:hover { border-color: var(--learn-good); }
.learn-gbtn.g-no:hover { border-color: var(--learn-bad); }

.learn-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }

/* Pomodoro */
.learn-pomo {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--soft);
  flex-wrap: wrap;
}
.learn-pomo[hidden] { display: none; }
.learn-pomo.flash { animation: pomo-flash .9s ease; }
.pomo-ring { position: relative; width: 96px; height: 96px; flex: 0 0 auto; }
.pomo-ring svg { transform: rotate(-90deg); }
.pomo-ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring-bg { stroke: var(--soft); }
.ring-fg {
  stroke: #ff6a2b;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1s linear, stroke .4s ease;
}
.learn-pomo.break .ring-fg { stroke: var(--learn-good); }
.pomo-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.pomo-emoji {
  font-size: 20px;
  line-height: 1;
  animation: pomo-bob 3.4s ease-in-out infinite;
  will-change: transform;
}
.pomo-clock { font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.pomo-side { flex: 1; min-width: 170px; }
.pomo-phase { font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; }
.learn-pomo.break .pomo-phase { color: var(--learn-good); }
.pomo-hint { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.learn-pomo-btns { display: flex; gap: 6px; }
.learn-pomo-btns button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  border-radius: 9px;
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.learn-pomo-btns button:hover { border-color: var(--accent); }

/* ---------- playful feedback ---------- */
.learn-stage { position: relative; }
.learn-stage.card-in { animation: card-in .28s ease; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.xp-pop {
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 5;
  font-weight: 700;
  font-size: 14px;
  color: #ff8a3d;
  pointer-events: none;
  animation: xp-pop .85s ease-out forwards;
}
@keyframes xp-pop {
  0% { opacity: 0; transform: translateY(6px) scale(.9); }
  30% { opacity: 1; transform: translateY(-4px) scale(1.05); }
  100% { opacity: 0; transform: translateY(-26px) scale(1); }
}
.learn-summary { position: relative; overflow: hidden; }
.cf {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  opacity: .95;
  pointer-events: none;
  animation-name: cf-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
@keyframes cf-fall {
  0% { transform: translateY(0) rotate(0); opacity: .95; }
  100% { transform: translateY(280px) rotate(540deg); opacity: 0; }
}
@keyframes pomo-bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.08); }
}
@keyframes pomo-flash {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 106, 43, 0); }
  30% { box-shadow: inset 0 0 0 3px rgba(255, 106, 43, .55); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 106, 43, 0); }
}
.learn-src { font-size: 12px; margin: -8px 0 12px; }
.learn-src a { color: var(--accent); }

/* picker + summary */
.learn-picker { padding: 20px 16px 24px; }
.learn-picker p { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.learn-picker-subjects { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.learn-subj {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.learn-subj[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.learn-subj:hover { border-color: var(--accent); }
.learn-loading { padding: 34px 16px; color: var(--muted); text-align: center; }

.learn-summary { padding: 26px 20px 30px; text-align: center; }
.learn-summary h3 { font-size: 22px; margin: 4px 0 6px; }
.learn-summary .learn-bigemoji { font-size: 52px; line-height: 1; }
.learn-summary-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 16px 0; }
.learn-summary-stat {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 14px;
  padding: 12px 18px;
  min-width: 96px;
}
.learn-summary-stat b { display: block; font-size: 22px; }
.learn-summary-stat small { color: var(--muted); font-size: 12px; }

.learn-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.learn-badge {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.learn-xpwrap { display: none; }

.learn-openlink { font-size: 13px; }

@media (max-width: 860px) {
  .learn-widget-grid { grid-template-columns: 1fr; }
  .learn-widget-grid::before { display: none; }
  .learn-glow { left: 0; }
  .learn-panel + .learn-panel { border-left: 0; border-top: 1px solid var(--learn-border); }
  .bento { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .learn-grades { grid-template-columns: repeat(2, 1fr); }
  .learn-dialog-title .learn-method { display: none; }
  .lvl-name { display: none; }
  .discover { padding-left: 14px; padding-right: 14px; }
}
