/* ============================================================
   v2-polish.css — Comprehensive UI/UX uplift
   ------------------------------------------------------------
   This layer sits on top of all existing CSS. Targets:
     1. Header   : glassmorphism on scroll, refined logo
     2. Hero     : brand gradient backdrop, time-of-day greeting
     3. Cards    : layered shadows, hover lift, gradient borders
     4. Tabbar   : floating glass with active pill indicator
     5. Buttons  : gradient primary, refined hover states
     6. Forms    : animated focus rings, better field styling
     7. Sidebar  : pill-style active state
     8. Loading  : skeleton placeholders
     9. Motion   : page-load cascade, button press, card hover
    10. Mobile   : larger touch targets, safer spacing
   ============================================================ */

/* ──────────────────────────────────────────────────────────
   Tokens additions
   ────────────────────────────────────────────────────────── */
:root {
  --glass-blur: saturate(140%) blur(18px);
  --shadow-card: 0 1px 2px oklch(20% 0.02 275 / 0.04),
                 0 6px 16px oklch(20% 0.02 275 / 0.06),
                 0 24px 48px oklch(20% 0.02 275 / 0.06);
  --shadow-card-hover: 0 4px 8px oklch(54% 0.23 275 / 0.10),
                       0 20px 40px oklch(54% 0.23 275 / 0.14),
                       0 30px 60px oklch(54% 0.23 275 / 0.10);
  --ring-focus: 0 0 0 3px oklch(54% 0.23 275 / 0.18);
  --ring-focus-strong: 0 0 0 3px oklch(54% 0.23 275 / 0.32);
}

@media (prefers-color-scheme: dark) {
  :root {
    --shadow-card: 0 1px 2px oklch(0% 0 0 / 0.4),
                   0 8px 20px oklch(0% 0 0 / 0.4),
                   0 24px 48px oklch(0% 0 0 / 0.5);
    --shadow-card-hover: 0 4px 8px oklch(54% 0.23 275 / 0.5),
                         0 20px 40px oklch(54% 0.23 275 / 0.4),
                         0 30px 60px oklch(0% 0 0 / 0.5);
  }
}

/* ──────────────────────────────────────────────────────────
   1. Header — sticky glass, refined logo
   ────────────────────────────────────────────────────────── */
.app-header {
  background: oklch(99% 0.003 265 / 0.78) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid oklch(91% 0.012 275 / 0.6);
  position: sticky;
  top: 0;
  z-index: 50;
}

@media (prefers-color-scheme: dark) {
  .app-header {
    background: oklch(15% 0.018 275 / 0.78) !important;
    border-bottom-color: oklch(30% 0.02 275 / 0.5);
  }
}

.app-header__logo-icon {
  background: var(--gradient-brand);
  box-shadow: 0 6px 16px oklch(54% 0.23 275 / 0.35);
  border: none;
  position: relative;
  overflow: hidden;
}

.app-header__logo-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, oklch(100% 0 0 / 0.35) 0%, transparent 60%);
  pointer-events: none;
}

.app-header__logo-icon span {
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

.app-header__logo:hover .app-header__logo-icon {
  transform: scale(1.04) rotate(-2deg);
}

.app-header__logo-icon {
  transition: transform 220ms var(--ease-out-quart);
}

/* Top menu items: pill-style active */
.app-menu__item {
  position: relative;
  border-radius: var(--radius-full);
  padding: 8px 14px;
  font-weight: 500;
  transition: background 160ms ease, color 160ms ease;
}

.app-menu__item:hover {
  background: oklch(95% 0.005 280);
  color: var(--color-primary);
}

.app-menu__item[aria-current="true"] {
  background: var(--gradient-brand-soft);
  color: var(--color-primary-dark);
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .app-menu__item:hover {
    background: oklch(28% 0.02 280);
    color: oklch(95% 0.005 280);
  }
  .app-menu__item[aria-current="true"] {
    color: oklch(85% 0.1 275);
  }
}

.app-chip {
  background: var(--gradient-brand-soft);
  color: var(--color-primary-dark);
  border: 1px solid var(--color-border-brand);
  font-weight: 600;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
}

/* ──────────────────────────────────────────────────────────
   2. Hero — branded backdrop with subtle glow
   ────────────────────────────────────────────────────────── */
.dashboard__hero {
  position: relative;
  padding: clamp(32px, 5vw, 56px) clamp(20px, 3vw, 32px);
  border-radius: 28px;
  background:
    radial-gradient(ellipse at 80% -20%, oklch(85% 0.12 275 / 0.25) 0%, transparent 55%),
    radial-gradient(ellipse at -10% 110%, oklch(85% 0.10 180 / 0.20) 0%, transparent 55%),
    var(--color-surface-raised);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  isolation: isolate;
  margin-bottom: var(--space-8, 2rem);
}

.dashboard__hero::before {
  content: "";
  position: absolute;
  top: -120px;
  right: -120px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: var(--gradient-brand);
  opacity: 0.10;
  filter: blur(60px);
  z-index: 0;
  pointer-events: none;
}

.dashboard__hero > * {
  position: relative;
  z-index: 1;
}

.dashboard__hero-kicker {
  display: inline-block;
  margin: 0 0 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 4px 12px oklch(54% 0.23 275 / 0.30);
}

.dashboard__hero-title {
  margin: 0 0 12px;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, var(--color-text) 30%, oklch(40% 0.04 275) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.dashboard__hero-sub {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-muted);
  max-width: 56ch;
}

.dashboard__hero-sub strong {
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  .dashboard__hero-sub strong {
    color: oklch(85% 0.1 275);
  }
}

.dashboard__hero-progress {
  margin-top: 18px;
  max-width: 320px;
}

.dashboard__hero-progress-track {
  height: 8px;
  background: oklch(94% 0.005 280);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.dashboard__hero-progress-fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: 999px;
  transition: width 800ms var(--ease-out-expo);
  box-shadow: 0 0 12px oklch(54% 0.23 275 / 0.4);
  position: relative;
}

.dashboard__hero-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    oklch(100% 0 0 / 0.4) 50%,
    transparent 100%
  );
  animation: v2-shimmer 2.5s infinite;
}

@keyframes v2-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@media (prefers-color-scheme: dark) {
  .dashboard__hero-progress-track {
    background: oklch(28% 0.02 280);
  }
}

@media (prefers-color-scheme: dark) {
  .dashboard__hero-title {
    background: linear-gradient(180deg, oklch(98% 0.005 275) 30%, oklch(75% 0.03 275) 100%);
    -webkit-background-clip: text;
    background-clip: text;
  }
}

/* Section heads */
.dashboard__section {
  margin-top: var(--space-8, 2rem);
}

.dashboard__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 0 4px;
}

.dashboard__section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.dashboard__section-link {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ──────────────────────────────────────────────────────────
   3. Course cards — premium feel with gradient header strip
   ────────────────────────────────────────────────────────── */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.course-card {
  background: var(--color-surface-raised) !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: var(--shadow-card) !important;
  border-radius: 20px !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform 280ms var(--ease-out-expo),
              box-shadow 280ms var(--ease-out-expo),
              border-color 200ms ease !important;
  min-height: 220px;
  cursor: pointer;
}

.course-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: var(--gradient-brand);
  opacity: 0.08;
  z-index: 0;
  transition: opacity 280ms ease;
  transform: none !important;
}

.course-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-brand);
  z-index: 1;
  border-radius: 20px 20px 0 0;
  transition: height 280ms var(--ease-out-expo);
}

.course-card:hover {
  transform: translateY(-6px) !important;
  box-shadow: var(--shadow-card-hover) !important;
  border-color: var(--color-border-brand) !important;
}

.course-card:hover::before {
  opacity: 0.16;
}

.course-card:hover::after {
  height: 6px;
}

.course-card:active {
  transform: translateY(-2px) scale(0.99) !important;
  transition-duration: 100ms !important;
}

.course-card > * {
  position: relative;
  z-index: 1;
  padding-left: 20px;
  padding-right: 20px;
}

.course-card__kicker {
  display: inline-block;
  margin: 24px 20px 8px !important;
  padding: 4px 10px;
  border-radius: 999px;
  background: oklch(99% 0.003 265 / 0.85);
  border: 1px solid var(--color-border-brand);
  color: var(--color-primary-dark) !important;
  font-size: 10px !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase;
  font-weight: 700 !important;
  width: fit-content;
  padding-left: 12px !important;
  padding-right: 12px !important;
  backdrop-filter: blur(8px);
}

.course-card__title {
  margin: 8px 0 6px !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
  letter-spacing: -0.005em;
}

.course-card__desc {
  margin: 0 0 16px !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  color: var(--color-text-muted) !important;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card__progress-track {
  height: 6px !important;
  background: oklch(94% 0.005 280) !important;
  border-radius: 999px !important;
  overflow: hidden;
  margin-bottom: 10px;
}

.course-card__progress-fill {
  height: 100% !important;
  background: var(--gradient-brand) !important;
  border-radius: 999px;
  transition: width 600ms var(--ease-out-expo) !important;
  box-shadow: 0 0 8px oklch(54% 0.23 275 / 0.4);
}

.course-card__meta {
  font-size: 12px !important;
  padding-bottom: 18px !important;
  margin-top: 0 !important;
}

.course-card__badge {
  font-size: 10px !important;
  padding: 3px 10px !important;
  border-radius: 999px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em;
  background: var(--color-surface-sunken) !important;
  color: var(--color-text-muted) !important;
  border: 1px solid var(--color-border);
}

.course-card__badge--active {
  background: var(--gradient-brand) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 4px 10px oklch(54% 0.23 275 / 0.30);
}

@media (prefers-color-scheme: dark) {
  .course-card__progress-track {
    background: oklch(28% 0.02 280) !important;
  }
  .course-card__kicker {
    background: oklch(22% 0.02 275 / 0.85);
  }
}

/* ──────────────────────────────────────────────────────────
   4. Mobile tabbar — floating glass with pill indicator
   ────────────────────────────────────────────────────────── */
.mobile-tabbar {
  background: oklch(99% 0.003 265 / 0.85) !important;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid oklch(91% 0.012 275 / 0.5) !important;
  box-shadow: 0 -10px 30px oklch(20% 0.02 275 / 0.06);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-tabbar__list {
  padding: 4px 4px 6px !important;
}

.mobile-tabbar__item {
  position: relative;
  border-radius: 14px !important;
  padding: 6px 4px !important;
  gap: 4px !important;
  transition: background 180ms ease, transform 180ms ease;
}

.mobile-tabbar__item span:last-child {
  font-size: 10.5px !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  transition: color 180ms ease;
}

.mobile-tabbar__item:active {
  transform: scale(0.94);
  background: oklch(95% 0.005 280);
}

.mobile-tabbar__item[aria-current="true"] {
  background: var(--gradient-brand-soft);
}

.mobile-tabbar__item[aria-current="true"] span:last-child {
  color: var(--color-primary-dark);
  font-weight: 700;
}

.mobile-tabbar__item[aria-current="true"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px !important;
  height: 3px !important;
  background: var(--gradient-brand) !important;
  border-radius: 0 0 3px 3px !important;
}

@media (prefers-color-scheme: dark) {
  .mobile-tabbar {
    background: oklch(15% 0.018 275 / 0.85) !important;
    border-top-color: oklch(30% 0.02 275 / 0.5) !important;
  }
  .mobile-tabbar__item:active {
    background: oklch(28% 0.02 280);
  }
  .mobile-tabbar__item[aria-current="true"] span:last-child {
    color: oklch(90% 0.08 275);
  }
}

/* ──────────────────────────────────────────────────────────
   5. Buttons — refined gradient + states
   ────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 120ms ease,
              box-shadow 200ms ease,
              background 180ms ease,
              border-color 180ms ease,
              color 180ms ease;
  white-space: nowrap;
  letter-spacing: 0.01em;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-focus-strong);
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--gradient-brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px oklch(54% 0.23 275 / 0.30),
              0 1px 0 oklch(100% 0 0 / 0.3) inset;
}

.btn--primary:hover {
  box-shadow: 0 8px 24px oklch(54% 0.23 275 / 0.45),
              0 1px 0 oklch(100% 0 0 / 0.3) inset;
  transform: translateY(-1px);
}

.btn--primary:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 10px oklch(54% 0.23 275 / 0.30),
              0 1px 0 oklch(100% 0 0 / 0.3) inset;
}

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

.btn--ghost:hover {
  background: oklch(96% 0.005 280);
  border-color: var(--color-border-strong);
}

.btn--ghost:active {
  background: oklch(94% 0.005 280);
}

.btn--danger {
  background: var(--color-danger);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 16px oklch(58% 0.2 28 / 0.3);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

@media (prefers-color-scheme: dark) {
  .btn--ghost:hover {
    background: oklch(28% 0.02 280);
  }
  .btn--ghost:active {
    background: oklch(32% 0.02 280);
  }
}

/* ──────────────────────────────────────────────────────────
   6. Forms — animated focus + better field
   ────────────────────────────────────────────────────────── */
.form__field {
  position: relative;
  margin-bottom: 16px;
}

.form__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.form__input,
.form__textarea,
.form__select {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  border-radius: 12px;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text);
  font-family: inherit;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
  -webkit-appearance: none;
  appearance: none;
}

.form__input:hover,
.form__textarea:hover,
.form__select:hover {
  border-color: var(--color-border-strong);
}

.form__input:focus,
.form__textarea:focus,
.form__select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--ring-focus);
  background: var(--color-surface-raised);
}

.form__input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form__textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.6;
}

.form__error {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: oklch(97% 0.04 28);
  color: oklch(40% 0.18 28);
  font-size: 13px;
  border: 1px solid oklch(80% 0.1 28);
}

@media (prefers-color-scheme: dark) {
  .form__error {
    background: oklch(28% 0.05 28);
    color: oklch(85% 0.1 28);
    border-color: oklch(45% 0.1 28);
  }
}

/* ──────────────────────────────────────────────────────────
   7. Cards globally
   ────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow-card);
  transition: box-shadow 220ms ease, border-color 200ms ease;
}

.card:hover {
  border-color: var(--color-border-strong);
}

.card__title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

/* ──────────────────────────────────────────────────────────
   8. Sidebar — pill active state
   ────────────────────────────────────────────────────────── */
.sidebar__item {
  position: relative;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  transition: background 160ms ease, color 160ms ease, padding-left 160ms ease;
}

.sidebar__item:hover {
  background: oklch(95% 0.005 280);
  padding-left: 18px;
}

.sidebar__item[aria-current="true"] {
  background: var(--gradient-brand-soft);
  color: var(--color-primary-dark);
  font-weight: 600;
}

.sidebar__item[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gradient-brand);
  border-radius: 2px;
}

@media (prefers-color-scheme: dark) {
  .sidebar__item:hover {
    background: oklch(28% 0.02 280);
  }
}

/* ──────────────────────────────────────────────────────────
   9. Profile screen polish
   ────────────────────────────────────────────────────────── */
.profile__avatar {
  background: var(--gradient-brand) !important;
  color: #fff !important;
  font-weight: 800 !important;
  font-size: 28px !important;
  box-shadow: 0 8px 24px oklch(54% 0.23 275 / 0.35);
  border: 3px solid var(--color-surface-raised);
  position: relative;
}

.profile__avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, oklch(100% 0 0 / 0.3) 0%, transparent 60%);
  pointer-events: none;
}

.profile__name {
  font-size: 22px !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
  margin-bottom: 4px !important;
}

.profile__email {
  font-size: 13px !important;
  color: var(--color-text-muted) !important;
}

/* ──────────────────────────────────────────────────────────
   10. Page-load motion (cascading fade-up)
   ────────────────────────────────────────────────────────── */
.dashboard > * {
  animation: v2-fadeup 600ms var(--ease-out-expo) backwards;
}

.dashboard__hero { animation-delay: 0ms; }
.dashboard__section:nth-of-type(1) { animation-delay: 80ms; }
.dashboard__section:nth-of-type(2) { animation-delay: 160ms; }
.dashboard__section:nth-of-type(3) { animation-delay: 240ms; }
.dashboard__section:nth-of-type(4) { animation-delay: 320ms; }

.course-card {
  animation: v2-fadeup 500ms var(--ease-out-expo) backwards;
}

.course-grid > .course-card:nth-child(1) { animation-delay: 50ms; }
.course-grid > .course-card:nth-child(2) { animation-delay: 100ms; }
.course-grid > .course-card:nth-child(3) { animation-delay: 150ms; }
.course-grid > .course-card:nth-child(4) { animation-delay: 200ms; }
.course-grid > .course-card:nth-child(5) { animation-delay: 250ms; }
.course-grid > .course-card:nth-child(6) { animation-delay: 300ms; }

@keyframes v2-fadeup {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard > *,
  .course-card {
    animation: none !important;
  }
}

/* ──────────────────────────────────────────────────────────
   11. Toasts — better positioning + variants
   ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0) + 88px);
  transform: translateX(-50%) translateY(20px);
  padding: 12px 18px;
  border-radius: 14px;
  background: oklch(15% 0.02 280);
  color: oklch(98% 0.005 275);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 16px 40px oklch(0% 0 0 / 0.3);
  z-index: 9500;
  opacity: 0;
  transition: opacity 220ms ease, transform 280ms var(--ease-out-expo);
  max-width: calc(100vw - 40px);
  text-align: center;
  pointer-events: none;
}

.toast--visible,
.toast[data-visible="true"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast--success {
  background: linear-gradient(135deg, oklch(45% 0.18 165), oklch(50% 0.16 145));
}

.toast--error,
.toast--danger {
  background: linear-gradient(135deg, oklch(45% 0.22 28), oklch(50% 0.20 18));
}

.toast--warn {
  background: linear-gradient(135deg, oklch(55% 0.18 75), oklch(60% 0.18 65));
  color: oklch(15% 0.05 75);
}

@media (min-width: 1024px) {
  .toast {
    bottom: 32px;
  }
}

/* ──────────────────────────────────────────────────────────
   12. Skeleton loader
   ────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    oklch(94% 0.005 280) 0%,
    oklch(97% 0.005 280) 50%,
    oklch(94% 0.005 280) 100%
  );
  background-size: 200% 100%;
  animation: v2-skeleton 1.5s infinite linear;
  border-radius: 8px;
  display: block;
}

@keyframes v2-skeleton {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (prefers-color-scheme: dark) {
  .skeleton {
    background: linear-gradient(
      90deg,
      oklch(22% 0.02 280) 0%,
      oklch(28% 0.02 280) 50%,
      oklch(22% 0.02 280) 100%
    );
    background-size: 200% 100%;
  }
}

/* ──────────────────────────────────────────────────────────
   13. Body / main rhythm
   ────────────────────────────────────────────────────────── */
body {
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.main {
  padding: clamp(16px, 3vw, 32px);
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Better scrollbar (desktop) */
@media (pointer: fine) {
  * {
    scrollbar-width: thin;
    scrollbar-color: oklch(80% 0.02 275) transparent;
  }
  *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  *::-webkit-scrollbar-thumb {
    background: oklch(80% 0.02 275);
    border-radius: 999px;
  }
  *::-webkit-scrollbar-thumb:hover {
    background: oklch(70% 0.04 275);
  }
}

/* ──────────────────────────────────────────────────────────
   13a. Auth screen — premium glass card + brand polish
   ────────────────────────────────────────────────────────── */
.auth-screen {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 32px);
  background:
    radial-gradient(ellipse at 18% 10%, oklch(95% 0.05 275 / 0.85) 0%, transparent 55%),
    radial-gradient(ellipse at 82% 95%, oklch(95% 0.05 180 / 0.7) 0%, transparent 50%),
    var(--color-surface);
  isolation: isolate;
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {
  .auth-screen {
    background:
      radial-gradient(ellipse at 18% 10%, oklch(28% 0.08 275 / 0.6) 0%, transparent 55%),
      radial-gradient(ellipse at 82% 95%, oklch(25% 0.06 180 / 0.55) 0%, transparent 50%),
      oklch(15% 0.018 275);
  }
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: clamp(24px, 5vw, 40px);
  border-radius: 24px;
  background: oklch(99% 0.003 265 / 0.92);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid oklch(91% 0.012 275 / 0.6);
  box-shadow:
    0 1px 0 oklch(100% 0 0 / 0.5) inset,
    0 24px 48px oklch(54% 0.23 275 / 0.15),
    0 8px 24px oklch(20% 0.02 275 / 0.10);
  animation: v2-fadeup 500ms var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)) backwards;
}

@media (prefers-color-scheme: dark) {
  .auth-card {
    background: oklch(20% 0.02 275 / 0.92);
    border-color: oklch(30% 0.02 275 / 0.5);
  }
}

.auth-card__brand-icon {
  width: 72px !important;
  height: 72px !important;
  border-radius: 22px !important;
  box-shadow:
    0 8px 24px oklch(54% 0.23 275 / 0.4),
    inset 0 1px 0 oklch(100% 0 0 / 0.5),
    inset 0 -12px 22px oklch(0% 0 0 / 0.15) !important;
}

.auth-card__title {
  font-size: clamp(20px, 3vw, 26px) !important;
  font-weight: 800 !important;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, var(--color-text) 30%, oklch(40% 0.04 275) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

@media (prefers-color-scheme: dark) {
  .auth-card__title {
    background: linear-gradient(180deg, oklch(98% 0.005 275) 30%, oklch(75% 0.03 275) 100%);
    -webkit-background-clip: text;
    background-clip: text;
  }
}

.auth-card__subtitle {
  font-size: 12px !important;
  color: var(--color-text-muted) !important;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: oklch(95% 0.005 280);
  border-radius: 14px;
  margin-bottom: 20px;
}

.auth-tabs__btn {
  min-height: 40px;
  border: none;
  background: transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}

.auth-tabs__btn:hover {
  color: var(--color-text);
}

.auth-tabs__btn[aria-selected="true"] {
  background: var(--color-surface-raised);
  color: var(--color-primary);
  box-shadow: 0 2px 8px oklch(20% 0.02 275 / 0.08);
}

@media (prefers-color-scheme: dark) {
  .auth-tabs {
    background: oklch(26% 0.02 280);
  }
  .auth-tabs__btn[aria-selected="true"] {
    background: oklch(34% 0.04 280);
  }
}

.auth-card .form__input,
.auth-card .form__select,
.auth-card .form__textarea {
  font-size: 15px;
  min-height: 46px;
  border-radius: 12px;
  border-width: 1.5px;
}

.auth-card .btn--primary {
  width: 100%;
  font-size: 15px;
  min-height: 50px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-top: 8px;
}

.auth-card .btn--block {
  width: 100%;
}

.auth-card__footer {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-card__footer a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  transition: color 160ms ease;
}

.auth-card__footer a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

.auth-card__hint {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
  padding: 8px 12px;
  border-radius: 10px;
  background: oklch(96% 0.005 280);
}

@media (prefers-color-scheme: dark) {
  .auth-card__hint {
    background: oklch(26% 0.02 280);
  }
}

/* ──────────────────────────────────────────────────────────
   13d. Course empty state + dashboard error
   ────────────────────────────────────────────────────────── */
.course-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: clamp(28px, 5vw, 48px) 24px;
  border-radius: 20px;
  background: oklch(96% 0.005 280);
  border: 1px dashed var(--color-border-strong, oklch(82% 0.015 275));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
@media (prefers-color-scheme: dark) {
  .course-empty {
    background: oklch(22% 0.02 280);
  }
}
.course-empty__icon {
  font-size: 36px;
  margin-bottom: 4px;
}
.course-empty__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.course-empty__hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text-muted);
  max-width: 40ch;
}

.dashboard-error {
  display: grid;
  place-items: center;
  min-height: 60dvh;
  padding: 24px;
}
.dashboard-error__card {
  width: 100%;
  max-width: 480px;
  padding: clamp(24px, 4vw, 32px);
  border-radius: 20px;
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-card);
  text-align: center;
}
.dashboard-error__icon {
  font-size: 40px;
  margin-bottom: 8px;
}
.dashboard-error__title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}
.dashboard-error__lead {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-muted);
}
.dashboard-error__detail {
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  background: oklch(96% 0.005 280);
  color: var(--color-text-muted);
  padding: 10px 12px;
  border-radius: 10px;
  overflow: auto;
  max-height: 120px;
  white-space: pre-wrap;
  word-break: break-all;
}
@media (prefers-color-scheme: dark) {
  .dashboard-error__detail {
    background: oklch(26% 0.02 280);
  }
}
.dashboard-error__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.dashboard-error__actions .btn {
  width: 100%;
}

/* ──────────────────────────────────────────────────────────
   13c. Invite-switch dialog (logged-in user opens invite URL)
   ────────────────────────────────────────────────────────── */
.invite-switch-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-items: center;
  background: oklch(15% 0.02 280 / 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}

.invite-switch-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

.invite-switch-card {
  width: 100%;
  max-width: 440px;
  padding: clamp(24px, 4vw, 32px);
  border-radius: 24px;
  background: var(--color-surface-raised, #fff);
  text-align: center;
  box-shadow: 0 24px 48px oklch(0% 0 0 / 0.25);
  transform: translateY(16px) scale(0.97);
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.invite-switch-overlay--visible .invite-switch-card {
  transform: translateY(0) scale(1);
}

.invite-switch-card__icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.invite-switch-card__title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.invite-switch-card__lead {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text-muted);
}

.invite-switch-card__lead strong {
  color: var(--color-primary-dark);
}

.invite-switch-card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-switch-card__actions .btn {
  width: 100%;
  min-height: 46px;
}

/* ──────────────────────────────────────────────────────────
   13b. Auth invite banner — make it pop
   ────────────────────────────────────────────────────────── */
.auth-invite-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--gradient-brand) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 8px 24px oklch(54% 0.23 275 / 0.30);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.auth-invite-banner::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: oklch(100% 0 0 / 0.15);
  pointer-events: none;
}

.auth-invite-banner--bootstrap {
  background: linear-gradient(135deg, oklch(50% 0.18 30), oklch(55% 0.20 50)) !important;
  box-shadow: 0 8px 24px oklch(50% 0.18 30 / 0.30);
}

.auth-invite-banner--invalid {
  background: linear-gradient(135deg, oklch(55% 0.20 30), oklch(50% 0.22 18)) !important;
  box-shadow: 0 8px 24px oklch(50% 0.22 28 / 0.30);
}

.auth-invite-banner__icon {
  font-size: 28px;
  line-height: 1;
  z-index: 1;
}

.auth-invite-banner__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #fff !important;
  z-index: 1;
}

.auth-invite-banner__sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: oklch(98% 0.005 275) !important;
  opacity: 0.92;
  z-index: 1;
}

/* ──────────────────────────────────────────────────────────
   14. iOS PWA install modal — refined
   ────────────────────────────────────────────────────────── */
.pwa-install-modal__title {
  background: linear-gradient(180deg, var(--color-text) 30%, oklch(40% 0.04 275) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.pwa-install-modal__primary {
  background: var(--gradient-brand) !important;
  box-shadow: 0 8px 24px oklch(54% 0.23 275 / 0.35) !important;
}

/* ──────────────────────────────────────────────────────────
   15. Mobile-only refinements
   ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .dashboard__hero {
    border-radius: 22px;
    padding: 28px 22px;
  }

  .dashboard__hero-title {
    font-size: 22px;
  }

  .course-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .course-card {
    min-height: 180px;
  }

  /* ボディ下部にモバイル tabbar 分の余白 */
  body[data-auth="true"]:not([data-route="lesson"]) .main {
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + 90px);
  }
}


/* ============================================
   Scroll safeguard (2026-05-11 final)
   v2-responsive.css の overflow-x:clip 修正と組み合わせ、
   html level での縦スクロールを明示保証。
   ============================================ */
html {
  overflow-y: auto;
}
