/* YUNELO V27.2 shared design system: one theme, fluid layout and accessible states for every screen
   (user app, admin and games). Load this LAST in <head> so it wins over page-local CSS. */
:root {
  color-scheme: dark;
  --yunelo-bg: #0d0818;
  --yunelo-surface: #171126;
  --yunelo-surface-raised: #211735;
  --yunelo-border: rgba(255,255,255,.10);
  --yunelo-text: #f8f7ff;
  --yunelo-muted: #b6afc7;
  --yunelo-primary: #8b5cf6;
  --yunelo-primary-strong: #7044e8;
  --yunelo-accent: #ff8a2a;
  --yunelo-success: #34d399;
  --yunelo-danger: #fb7185;
  --yunelo-radius-sm: 10px;
  --yunelo-radius-md: 16px;
  --yunelo-radius-lg: 22px;
  --yunelo-shadow: 0 16px 42px rgba(0,0,0,.24);
  --yunelo-ease: cubic-bezier(.2,.7,.2,1);
  --yunelo-speed-fast: 140ms;
  --yunelo-speed: 220ms;
}
html { scroll-behavior: smooth; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
body {
  color: var(--yunelo-text);
  font-family: Inter, Nunito, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; }
button, [role="button"], .btn, .button, .primary-btn, .secondary-btn, .premium-card, .buddy-card, .game-card {
  transition: color var(--yunelo-speed-fast) ease, background-color var(--yunelo-speed-fast) ease,
    border-color var(--yunelo-speed-fast) ease, box-shadow var(--yunelo-speed) var(--yunelo-ease),
    filter var(--yunelo-speed-fast) ease, transform var(--yunelo-speed-fast) var(--yunelo-ease);
}
button:enabled:hover, [role="button"]:hover, .btn:hover, .button:hover, .primary-btn:hover, .secondary-btn:hover {
  filter: brightness(1.06);
}
button:enabled:active, [role="button"]:active, .btn:active, .button:active { transform: translateY(1px) scale(.99); }
:where(button, a, input, select, textarea, [role="button"], [tabindex]):focus-visible {
  outline: 3px solid rgba(167,139,250,.92);
  outline-offset: 3px;
}
:where(button, input[type="submit"], input[type="button"], [role="button"]) { touch-action: manipulation; }
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  max-width: 100%;
  border-color: var(--yunelo-border);
  transition: border-color var(--yunelo-speed-fast) ease, box-shadow var(--yunelo-speed-fast) ease;
}
:where(input, select, textarea):focus { border-color: var(--yunelo-primary); box-shadow: 0 0 0 3px rgba(139,92,246,.15); }
:where(.card, .glass, .panel, .modal-content, .summary-card, .stat-card, .feature-card) {
  border-color: var(--yunelo-border);
  border-radius: var(--yunelo-radius-lg);
}
:where(img, video, canvas, svg) { max-width: 100%; }
img[loading="lazy"] { content-visibility: auto; }
:where(.error, .error-message, [role="alert"]) { overflow-wrap: anywhere; }
.yunelo-motion-in { animation: yuneloMotionIn 280ms var(--yunelo-ease) both; }
.yunelo-soft-pulse { animation: yuneloSoftPulse 1.8s ease-in-out infinite; }
.yunelo-skeleton {
  background: linear-gradient(100deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.10) 38%, rgba(255,255,255,.04) 52%);
  background-size: 220% 100%; animation: yuneloShimmer 1.35s linear infinite;
}
@keyframes yuneloMotionIn { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
@keyframes yuneloSoftPulse { 0%,100% { opacity: 1; } 50% { opacity: .72; } }
@keyframes yuneloShimmer { to { background-position-x: -220%; } }
@media (max-width: 380px) {
  :root { --yunelo-radius-lg: 18px; }
  body { overflow-wrap: anywhere; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0ms !important;
  }
  .yunelo-motion-in, .yunelo-soft-pulse, .yunelo-skeleton { animation: none !important; }
}

/* Consistent readable labels on legacy screens that still have local CSS. */
:where(.grammar-title, .stat-label, .reconnect-banner button, .eyebrow, .sub,
  .selector label, .stat-meta, .section-note, .skill-name, .skill-delta,
  .improve p, .session-meta, .empty, .daily-date b, .daily-date span,
  .daily-main strong, .daily-main span, .daily-score, .mistake-pill, .nav a) {
  font-size: max(12px, .875em) !important;
}
:where(.card, .glass, .panel, .summary-card, .stat-card, .feature-card, .buddy-card) {
  box-shadow: var(--yunelo-shadow);
}
body { background-color: var(--yunelo-bg); }

/* =====================================================================
   V27.2 — UNIFIED THEME + RESPONSIVE LAYER + FLOATING GLASS NAVBAR
   ===================================================================== */

/* ---- 1. Tokens ------------------------------------------------------ */
html:root {
  --yunelo-pink: #ec4899;
  --yunelo-warning: #fbbf24;
  --yunelo-info: #60a5fa;
  --yunelo-text-dim: #948cab;
  --yunelo-surface-glass: rgba(23, 17, 38, .78);
  --yunelo-radius-xl: 28px;
  --yunelo-gradient: linear-gradient(135deg, #8b5cf6 0%, #6d3df5 100%);
  --yunelo-gradient-warm: linear-gradient(135deg, #ff8a2a 0%, #ec4899 100%);

  /* Fluid layout: gutters and gaps follow the screen instead of fixed px. */
  --y-gutter: clamp(14px, 4.4vw, 24px);
  --y-gap: clamp(10px, 2.8vw, 16px);
  --y-shell: 520px;
  --y-nav-h: 66px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* Type scale: nothing readable drops below 12px; headings flex with width. */
  --y-fs-2xs: .6875rem;
  --y-fs-xs: .75rem;
  --y-fs-sm: .8125rem;
  --y-fs-md: .9375rem;
  --y-fs-lg: clamp(1.0625rem, .98rem + .4vw, 1.25rem);
  --y-fs-xl: clamp(1.25rem, 1.05rem + 1vw, 1.625rem);
  --y-fs-2xl: clamp(1.5rem, 1.05rem + 2.2vw, 2.25rem);
}

/* ---- 2. Global safety nets ----------------------------------------- */
:where(*, *::before, *::after) { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; scrollbar-color: rgba(139,92,246,.55) transparent; }
html, body { max-width: 100%; overflow-x: hidden; overflow-x: clip; }
body {
  min-height: 100vh; min-height: 100dvh;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(139,92,246,.45); color: #fff; }
::placeholder { color: var(--yunelo-text-dim); opacity: 1; }
:where(img, video) { height: auto; }
:where(iframe, table) { max-width: 100%; }
:where(h1, h2, h3, h4, p, li, td, th, label, button, a) { overflow-wrap: break-word; }
:where(pre, code) { white-space: pre-wrap; word-break: break-word; }

html .min-h-screen { min-height: 100vh; min-height: 100dvh; }
html .h-screen { height: 100vh; height: 100dvh; }
html .max-h-screen { max-height: 100vh; max-height: 100dvh; }

html .text-\[8px\], html .text-\[9px\], html .text-\[10px\] { font-size: var(--y-fs-2xs); }
html .text-\[11px\] { font-size: var(--y-fs-xs); }

@media (pointer: coarse) {
  :where(button, [role="button"], summary, select, input[type="submit"], input[type="button"]) { min-height: 44px; }
  :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) { font-size: max(16px, 1em); }
}

@media (max-width: 359px) {
  html:root { --y-gutter: 12px; --y-gap: 8px; }
  body { font-size: 15px; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .y-sheet__panel { max-height: calc(100dvh - 16px); }
}

@media (min-resolution: 2dppx) { :where(.y-card, .y-chip) { min-width: 0; } }

/* ---- 3. Shared components ------------------------------------------ */
.y-shell {
  width: 100%;
  max-width: var(--y-shell);
  margin-inline: auto;
  padding-inline: max(var(--y-gutter), var(--safe-left)) max(var(--y-gutter), var(--safe-right));
}
/* Unified 520px shell across all learner screens so tab switching never shifts layout width */
@media (min-width: 521px) { html:root { --y-shell: 520px; } }

.y-card {
  min-width: 0;
  background: var(--yunelo-surface-glass);
  border: 1px solid var(--yunelo-border);
  border-radius: var(--yunelo-radius-lg);
  box-shadow: var(--yunelo-shadow);
}

.y-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .75rem 1.25rem;
  border: 0; border-radius: var(--yunelo-radius-md);
  background: var(--yunelo-gradient); color: #fff;
  font-weight: 800; font-size: var(--y-fs-md); text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 0 #4c1d95, 0 14px 24px rgba(109,61,245,.35);
}
.y-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #4c1d95, 0 6px 12px rgba(109,61,245,.3); }
.y-btn[disabled], .y-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }
.y-btn--ghost { background: rgba(255,255,255,.06); border: 1px solid var(--yunelo-border); box-shadow: none; color: var(--yunelo-text); }

/* Dialog / bottom sheet shared by dashboard, store and profile popups. */
.y-sheet {
  position: fixed; inset: 0; z-index: 900;
  display: grid; place-items: center;
  padding: max(16px, var(--safe-top)) max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
  background: rgba(5, 2, 12, .74);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility 0s linear .2s;
}
.y-sheet.is-open { opacity: 1; visibility: visible; transition: opacity .2s ease; }
.y-sheet__panel {
  position: relative; width: min(100%, 380px);
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(18px, 5vw, 28px);
  border: 1px solid var(--yunelo-border); border-radius: var(--yunelo-radius-xl);
  background: var(--yunelo-surface); text-align: center;
  transform: scale(.96); transition: transform .2s var(--yunelo-ease);
}
.y-sheet.is-open .y-sheet__panel { transform: scale(1); }
.y-sheet__close {
  position: absolute; top: 10px; right: 10px; width: 44px; height: 44px;
  display: grid; place-items: center; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.08); color: #fff; font-size: 18px; cursor: pointer;
}

/* Toasts: polite, readable, never hidden behind the bottom nav. */
.y-toast-root {
  position: fixed; left: 0; right: 0; z-index: 1000;
  bottom: calc(var(--y-nav-h) + var(--safe-bottom) + 26px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding-inline: var(--y-gutter); pointer-events: none;
}
.y-toast {
  max-width: min(100%, 420px); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid rgba(167,139,250,.3); border-radius: 16px;
  background: rgba(21,13,40,.96); color: #fff;
  font-size: var(--y-fs-sm); font-weight: 700; line-height: 1.35;
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
  animation: yToastIn .24s var(--yunelo-ease) both;
}
.y-toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }
@keyframes yToastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--yunelo-radius-md); }
.table-wrap > table { min-width: 560px; }

/* ---- Unified Floating Glass Bottom Navigation (.y-nav & .floating-nav) ---- */
.y-nav,
.floating-nav {
  position: fixed !important;
  z-index: 95 !important;
  left: 50% !important;
  bottom: max(12px, var(--safe-bottom, 0px)) !important;
  transform: translateX(-50%) !important;
  width: min(calc(100% - 24px), 440px) !important; max-width: 440px !important;
  height: var(--y-nav-h) !important;
  padding: 0 10px !important;
  border: 1px solid rgba(167, 139, 250, 0.22) !important;
  border-radius: 28px !important;
  background: rgba(18, 12, 34, 0.92) !important;
  -webkit-backdrop-filter: blur(22px) !important;
  backdrop-filter: blur(22px) !important;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

.y-nav-in {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  justify-items: center;
  height: 100%;
  width: 100%;
}

.y-nav a:not(.y-nav-mic),
.floating-nav .nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 52px;
  min-height: 44px;
  border-radius: 18px;
  color: #948cab;
  font-size: 11px !important;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease, transform 0.15s ease;
}

.y-nav a:not(.y-nav-mic):hover,
.floating-nav .nav-item:hover {
  color: #e2dcf5;
  background: rgba(139, 92, 246, 0.08);
}

.y-nav a:not(.y-nav-mic)[aria-current="page"],
.y-nav a.is-active:not(.y-nav-mic),
.floating-nav .nav-item.active,
.floating-nav .nav-item[aria-current="page"] {
  color: #ffffff;
  font-weight: 800;
  background: rgba(139, 92, 246, 0.16);
}

.y-nav a:not(.y-nav-mic)[aria-current="page"] svg,
.y-nav a.is-active:not(.y-nav-mic) svg,
.floating-nav .nav-item.active svg {
  color: #c4b5fd;
  filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.55));
}

.y-nav a:not(.y-nav-mic)[aria-current="page"]::after,
.y-nav a.is-active:not(.y-nav-mic)::after,
.floating-nav .nav-item.active::after {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 16px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #a78bfa, #ec4899);
}

.y-nav a.y-nav-mic,
.floating-nav .nav-center-mic {
  position: relative;
  top: -16px;
  width: 58px !important;
  height: 58px !important;
  min-height: 58px !important;
  flex: none;
  margin-inline: clamp(6px, 2vw, 12px);
  border: 3px solid #0d0818;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7 0%, #6d28d9 100%);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 0 #4c1d95, 0 14px 26px rgba(139, 92, 246, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.32);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.y-nav a.y-nav-mic:hover,
.floating-nav .nav-center-mic:hover {
  filter: brightness(1.08);
}

.y-nav a.y-nav-mic:active,
.floating-nav .nav-center-mic:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #4c1d95, 0 6px 14px rgba(139, 92, 246, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.32);
}

.y-nav-mic::before,
.floating-nav .nav-center-mic::before {
  content: "";
  position: absolute;
  inset: -6px;
  z-index: -1;
  border-radius: 50%;
  background: #a855f7;
  filter: blur(14px);
  opacity: .48;
  animation: yMic 2.4s ease-in-out infinite;
}

@keyframes yMic { 50% { transform: scale(1.14); opacity: .26; } }

@media (max-height: 480px) and (orientation: landscape) {
  html:root { --y-nav-h: 54px; }
  .y-nav a.y-nav-mic, .floating-nav .nav-center-mic { top: -10px; width: 48px !important; height: 48px !important; min-height: 48px !important; }
  .y-nav a:not(.y-nav-mic), .floating-nav .nav-item { height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .y-nav-mic::before, .floating-nav .nav-center-mic::before { animation: none; }
}

.y-nav-mic[aria-current="page"],
.floating-nav .nav-mic-btn[aria-current="page"] {
  border-color: #f472b6 !important;
  box-shadow:
    0 6px 0 #4c1d95,
    0 0 0 4px rgba(236, 72, 153, 0.28),
    0 16px 32px rgba(236, 72, 153, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.38) !important;
}
