/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens — match eduplaner.pl exactly ─────────────────────────── */
:root {
  --bg:          #1a1a1a;
  --bg-card:     #242424;
  --bg-elevated: #2a2a2a;
  --bg-muted:    #333333;
  --border:      rgba(255,255,255,.05);
  --border-soft: rgba(255,255,255,.1);
  --border-med:  rgba(255,255,255,.15);
  --accent:      #4FA65A;
  --accent-mint: #7CC47C;
  --accent-soft: #A5D9A3;
  --accent-dim:  rgba(79,166,90,.12);
  --accent-glow: rgba(79,166,90,.35);
  --text:        #ffffff;
  --text-gray:   #D1D5DB;
  --text-muted:  #9CA3AF;
  --text-dark:   #6B7280;
  --danger:      #EF4444;
  --danger-dim:  rgba(239,68,68,.12);
  --warn:        #F59E0B;
  --shadow-green: 0 0 30px rgba(79,166,90,.35), 0 0 60px rgba(79,166,90,.1);
  --player-h:    152px;
  --header-h:    65px;
  --font:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { height: 100%; scroll-behavior: smooth; touch-action: manipulation; }

body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
  overflow: hidden;
}

/* ── Offline banner ──────────────────────────────────────────────────────── */
#offline-banner {
  background: var(--warn);
  color: #000;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 16px;
  display: none;
}
#offline-banner.visible { display: block; }

/* ── Header — matches website nav exactly ───────────────────────────────── */
.app-header {
  background: rgba(26,26,26,.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  /* Push header background under the iOS status bar / notch */
  padding-top: env(safe-area-inset-top);
  flex-shrink: 0;
  z-index: 10;
}

/* Inner row keeps content at the right height and respects side insets */
.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.logo-text {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
  line-height: 1;
}
.logo-accent { color: var(--accent); }
.logo-domain { color: var(--text-dark); font-size: 13px; font-weight: 500; }

.header-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid rgba(79,166,90,.2);
  border-radius: 999px;
  padding: 3px 10px 3px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100% { opacity:1; } 50% { opacity:.4; } }

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;   /* allow shrinking so right side is never pushed off screen */
  flex: 1;
}

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.header-icon-btn {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.header-icon-btn:hover {
  background: var(--accent-dim);
  border-color: rgba(79,166,90,.3);
  color: var(--accent);
}

.header-settings-btn {
  background: var(--bg-muted);
  border: 1px solid var(--border-soft);
  color: var(--text-gray);
  border-radius: 8px;
  padding: 0 14px;
  height: 36px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all .15s;
}
.header-settings-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Hide text label on very narrow screens — keep icon only */
@media (max-width: 380px) {
  .settings-btn-text { display: none; }
  .header-settings-btn { padding: 0 10px; }
}

/* Hide EduPlaner badge on mobile — not enough horizontal space */
@media (max-width: 540px) {
  .header-badge { display: none; }
}

/* ── Episodes container ───────────────────────────────────────────────────── */
#episodes-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--player-h) + 12px + env(safe-area-inset-bottom));
  scroll-behavior: smooth;
}

/* ── Status messages ─────────────────────────────────────────────────────── */
.status-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
  font-size: 14px;
  line-height: 1.6;
}
.status-icon { font-size: 40px; }
.status-message a { color: var(--accent); text-decoration: none; font-weight: 600; }
.status-message a:hover { text-decoration: underline; }
.status-message p strong { color: var(--text-gray); }

/* Demo banner — styled as an info card */
.demo-banner {
  background: var(--accent-dim);
  border: 1px solid rgba(79,166,90,.2);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 10px;
  line-height: 1.5;
}
.demo-banner a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Materials upsell card ───────────────────────────────────────────────── */
.mat-upsell-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 28px 20px;
  margin: 4px 0 16px;
}
.mat-upsell-icon { font-size: 32px; }
.mat-upsell-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 300px;
}
.mat-upsell-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  text-decoration: none;
  padding: 11px 20px;
  border-radius: 10px;
  transition: opacity .15s;
}
.mat-upsell-btn:hover { opacity: .85; }

/* ── Listening progress bar ──────────────────────────────────────────────── */
.listen-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 14px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.listen-progress.hidden { display: none; }

.lp-label-row { display: flex; justify-content: space-between; align-items: center; }
.lp-label     { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.lp-count     { font-size: 12px; font-weight: 700; color: var(--accent); }

.lp-track {
  height: 5px;
  background: var(--bg-muted);
  border-radius: 3px;
  overflow: hidden;
}
.lp-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width .4s ease;
}

/* ── Episodes list ───────────────────────────────────────────────────────── */
.episodes-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.episodes-list.hidden { display: none; }
.hidden { display: none !important; }

/* Episode card — matches website course card style */
.episode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;        /* rounded-2xl */
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, border-color .15s;
  position: relative;
  overflow: hidden;
}
.episode-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  border-color: var(--border-soft);
}
.episode-card.active {
  border-color: rgba(79,166,90,.4);
  background: linear-gradient(135deg, #242424 0%, #1d2b1f 100%);
  box-shadow: 0 0 0 1px rgba(79,166,90,.2), 0 8px 24px rgba(0,0,0,.3);
}

/* Episode number badge */
.ep-num {
  min-width: 36px; height: 36px;
  background: var(--bg-muted);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.episode-card.active .ep-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Episode info */
.ep-info { flex: 1; min-width: 0; }

.ep-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
  color: var(--text);
}

.ep-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.ep-desc {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.ep-duration { flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Cache status dot */
.cache-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--bg-muted);
  flex-shrink: 0;
  transition: background .2s, box-shadow .2s;
}
.cache-dot.cached {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(79,166,90,.6);
}
.cache-dot.downloading {
  background: var(--warn);
  animation: pulse-dot 1s ease-in-out infinite;
}

/* Episode action buttons */
.ep-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ep-play-btn {
  width: 36px; height: 36px;
  background: var(--accent-dim);
  border: 1px solid rgba(79,166,90,.25);
  color: var(--accent);
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.ep-play-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-green);
}
.ep-play-btn:active { transform: scale(.9); }

.ep-dl-btn {
  width: 32px; height: 32px;
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
}
.ep-dl-btn:hover {
  color: var(--accent);
  border-color: rgba(79,166,90,.3);
  background: var(--accent-dim);
}
.ep-dl-btn.cached:hover {
  color: var(--danger);
  border-color: rgba(239,68,68,.3);
  background: var(--danger-dim);
}
.ep-dl-btn:disabled { opacity: .5; cursor: default; }

/* Listen progress bar — always present, shows playback position */
.ep-listen-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255,255,255,.06);
  border-radius: 0 0 16px 16px;
  overflow: hidden;
}
.ep-listen-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .5s linear;
}
/* Fully listened — green glow */
.episode-card.listened .ep-listen-fill {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(79,166,90,.5);
}

/* Download progress bar — appears on top of listen bar during download */
.ep-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  display: none;
}
.ep-progress.active { display: block; }
.ep-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .3s;
  border-radius: 0 0 2px 2px;
}

/* ── Player bar ──────────────────────────────────────────────────────────── */
.player-bar {
  background: linear-gradient(145deg, #242424 0%, #1e1e1e 100%);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  /* bottom padding extends into iOS home-indicator area */
  padding: 12px max(20px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  gap: 10px;
}
.player-bar.hidden { display: none; }

/* Progress row */
.player-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.time-label {
  font-size: 11px;
  color: var(--text-dark);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  flex-shrink: 0;
  font-weight: 500;
}
.time-label.right { text-align: right; }

/* Scrub bar */
input[type=range].progress-bar {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  background: var(--bg-muted);
}
input[type=range].progress-bar::-webkit-slider-runnable-track {
  background: linear-gradient(
    to right,
    var(--accent) var(--pct, 0%),
    var(--bg-muted) var(--pct, 0%)
  );
  height: 4px; border-radius: 2px;
}
input[type=range].progress-bar::-moz-range-track { background: var(--bg-muted); height: 4px; border-radius: 2px; }
input[type=range].progress-bar::-moz-range-progress { background: var(--accent); height: 4px; border-radius: 2px; }
input[type=range].progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(79,166,90,.5);
  margin-top: -5px;
  cursor: pointer;
}
input[type=range].progress-bar::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

/* Info + speed row */
.player-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.player-title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.speed-select {
  background: var(--bg-muted);
  border: 1px solid var(--border-soft);
  color: var(--text-gray);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  min-width: 54px;
  flex-shrink: 0;
  transition: border-color .15s;
}
.speed-select:focus { outline: none; border-color: rgba(79,166,90,.5); }

/* Controls row */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ctrl-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  border-radius: 8px;
  height: 36px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px;
  transition: all .15s;
  letter-spacing: -.2px;
}
.ctrl-btn:hover {
  color: var(--text);
  border-color: var(--border-soft);
  background: rgba(255,255,255,.08);
}
.ctrl-btn:active { transform: scale(.93); }

/* Play/pause — green filled, website CTA style */
.ctrl-btn.play-pause {
  width: 48px; height: 48px;
  padding: 0;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 17px;
  box-shadow: 0 0 20px rgba(79,166,90,.3);
}
.ctrl-btn.play-pause:hover {
  background: var(--accent-mint);
  border-color: var(--accent-mint);
  box-shadow: var(--shadow-green);
}

/* ── Settings modal — matches website newsletter popup exactly ───────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-backdrop.hidden { display: none; }

.modal-sheet {
  position: relative;
  background: linear-gradient(145deg, #242424 0%, #1e1e1e 100%);
  border: 1px solid rgba(79,166,90,.25);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px calc(32px + env(safe-area-inset-bottom));
  width: 100%; max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 0 60px rgba(79,166,90,.12), 0 -16px 40px rgba(0,0,0,.5);
  animation: sheet-in .3s cubic-bezier(.34,1.56,.64,1) both;
}

@media (min-width: 600px) {
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal-sheet {
    border-radius: 24px;
    max-height: 80vh;
    animation: popup-in .35s cubic-bezier(.34,1.56,.64,1) both;
  }
}

@keyframes sheet-in {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes popup-in {
  from { transform: scale(.88) translateY(20px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  background: rgba(255,255,255,.06);
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.modal-close:hover { background: rgba(255,255,255,.12); color: #fff; }

.modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-dim);
  border: 1px solid rgba(79,166,90,.2);
  border-radius: 999px;
  padding: 4px 12px 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  align-self: flex-start;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: 4px;
}
.modal-header h2 span { color: var(--accent); }

.modal-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Auth step containers */
#auth-step-email,
#auth-step-code,
#auth-logged-in {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Form elements */
.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-group input {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: var(--font);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus {
  outline: none;
  border-color: rgba(79,166,90,.5);
  box-shadow: 0 0 0 3px rgba(79,166,90,.1);
}
.form-group input::placeholder { color: var(--text-dark); }

.hint {
  font-size: 12px;
  color: var(--text-dark);
  line-height: 1.6;
}
.app-version {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dark);
  vertical-align: middle;
}
.hint code {
  background: var(--bg-muted);
  border: 1px solid var(--border-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--text-muted);
}

/* Buttons — match website's button styles */
.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  width: 100%;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px rgba(79,166,90,.25);
}
.btn-primary:hover {
  background: var(--accent-mint);
  box-shadow: var(--shadow-green);
}

.btn-secondary {
  background: rgba(255,255,255,.05);
  color: var(--text-gray);
  border: 1px solid var(--border-soft);
}
.btn-secondary:hover {
  background: rgba(255,255,255,.08);
  border-color: var(--border-med);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.25);
}
.btn-danger:hover { background: rgba(239,68,68,.2); }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

.storage-info { display: flex; flex-direction: column; gap: 8px; }
.storage-info h3 { font-size: 14px; font-weight: 700; }
.storage-info p { font-size: 13px; color: var(--text-muted); }

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.shortcut-item {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.shortcut-item kbd {
  background: var(--bg-muted);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--text-gray);
  flex-shrink: 0;
}

/* ── Toasts ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  top: calc(var(--header-h) + env(safe-area-inset-top) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: min(340px, 90vw);
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  animation: toast-in .2s ease, toast-out .3s ease 2.7s forwards;
}
.toast.success { border-color: rgba(79,166,90,.4); color: var(--accent); }
.toast.error   { border-color: rgba(239,68,68,.4); color: var(--danger); }
.toast.info    { color: var(--text-gray); }

@keyframes toast-in  { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
#episodes-container::-webkit-scrollbar { width: 4px; }
#episodes-container::-webkit-scrollbar-track { background: transparent; }
#episodes-container::-webkit-scrollbar-thumb { background: var(--bg-muted); border-radius: 2px; }

/* ── Desktop layout ──────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  #episodes-container { padding: 20px 24px calc(var(--player-h) + 16px + env(safe-area-inset-bottom)); }
  .header-inner { padding: 0 max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left)); }
  .player-bar { padding: 12px max(28px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left)); }
}

/* ══════════════════════════════════════════════════════════════════════════
   TAB BAR
   ══════════════════════════════════════════════════════════════════════════ */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  padding: 12px 14px 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover  { color: var(--text-gray); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs-locked #tab-player-btn,
.tabs-locked #tab-flash-btn,
.tabs-locked #tab-plan-btn { display: none; }

/* ══════════════════════════════════════════════════════════════════════════
   FLASHCARD CONTAINER (replaces episodes-container when active)
   ══════════════════════════════════════════════════════════════════════════ */
#flashcard-container {
  flex: 1;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 14px 16px 20px;
  gap: 12px;
}
#flashcard-container.fc-active { display: flex; }

/* When flashcard tab is active, hide the player bar */
#flashcard-container.fc-active ~ .player-bar { display: none; }

/* ── Flashcard download loading bar ─────────────────────────────────────── */
#fc-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  flex: 1;
}
#fc-loading.hidden { display: none; }

.fc-loading-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.fc-loading-track {
  width: 100%;
  max-width: 280px;
  height: 6px;
  background: var(--bg-muted);
  border-radius: 3px;
  overflow: hidden;
}

.fc-loading-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-mint));
  border-radius: 3px;
  width: 0%;
  transition: width .3s ease;
}


.fc-loading-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ── Overall flashcard progress bar ─────────────────────────────────────── */
.fc-overall-prog {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}
.fc-overall-prog.hidden { display: none; }

.fc-op-row    { display: flex; justify-content: space-between; align-items: center; }
.fc-op-label  { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.fc-op-count  { font-size: 12px; font-weight: 700; color: var(--accent-mint); }

.fc-op-track {
  height: 5px;
  background: var(--bg-muted);
  border-radius: 3px;
  overflow: hidden;
}
.fc-op-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-mint));
  border-radius: 3px;
  width: 0%;
  transition: width .4s ease;
}

/* ── Day title ───────────────────────────────────────────────────────────── */
.fc-day-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 0 2px;
  flex-shrink: 0;
}
.fc-day-title.hidden { display: none; }

/* ── Header row: day selector + stats ────────────────────────────────────── */
.fc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#fc-day-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  min-width: 120px;
  transition: border-color .15s;
}
#fc-day-select:focus { outline: none; border-color: rgba(79,166,90,.5); }

.fc-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.fc-stat {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  color: var(--text-muted);
}
.fc-stat-new  .fc-stat-val { color: var(--accent); }
.fc-stat-rev  .fc-stat-val { color: var(--warn); }
.fc-stat-done .fc-stat-val { color: var(--text-dark); }

/* ── Session progress bar ────────────────────────────────────────────────── */
.fc-prog-track {
  height: 5px;
  background: var(--bg-muted);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
#fc-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width .4s ease;
}

/* ── Card area ───────────────────────────────────────────────────────────── */
#fc-card-area { flex: 1; display: flex; align-items: flex-start; }
#fc-card-area.hidden { display: none; }

/* The card itself */
.fc-card {
  background: linear-gradient(145deg, #242424 0%, #1e1e1e 100%);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 22px 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  animation: fc-in .2s ease;
}
@keyframes fc-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.fc-card-answer { border-color: rgba(79,166,90,.2); }

/* Card meta line */
.fc-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.fc-day-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(79,166,90,.2);
  border-radius: 999px;
  padding: 3px 10px;
}
.fc-queue-lbl {
  font-size: 12px;
  color: var(--text-dark);
  font-weight: 500;
}

/* Question (front) */
.fc-question {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.45;
  color: var(--text);
  letter-spacing: -.3px;
}

/* Reveal button */
.fc-reveal-btn {
  background: var(--accent);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  padding: 13px 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 0 20px rgba(79,166,90,.25);
  transition: background .15s, box-shadow .15s;
}
.fc-reveal-btn:hover {
  background: var(--accent-mint);
  box-shadow: var(--shadow-green);
}

/* Answer side */
.fc-question-mini {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.5;
}
.fc-divider {
  height: 1px;
  background: var(--border-soft);
}
.fc-answer {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.65;
  color: var(--text);
}
.fc-requirement {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--text-dark);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}
.fc-req-pin { flex-shrink: 0; font-size: 13px; }

/* ── Rating buttons ──────────────────────────────────────────────────────── */
.fc-rate-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
@media (max-width: 420px) {
  .fc-rate-row { grid-template-columns: repeat(2, 1fr); }
}

.fc-rate-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 6px 8px;
  cursor: pointer;
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all .15s;
}
.fc-rate-btn:hover   { transform: translateY(-2px); }
.fc-rate-btn:active  { transform: scale(.94); }

.fc-rate-label    { font-size: 13px; font-weight: 700; color: var(--text); }
.fc-rate-interval { font-size: 11px; color: var(--text-muted); }

/* Per-rating colours */
.fc-rate-again { border-color: rgba(239,68,68,.3); }
.fc-rate-again:hover { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.6); }
.fc-rate-again .fc-rate-label { color: #EF4444; }

.fc-rate-hard { border-color: rgba(245,158,11,.3); }
.fc-rate-hard:hover { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.6); }
.fc-rate-hard .fc-rate-label { color: #F59E0B; }

.fc-rate-good { border-color: rgba(79,166,90,.3); }
.fc-rate-good:hover { background: rgba(79,166,90,.1); border-color: rgba(79,166,90,.6); }
.fc-rate-good .fc-rate-label { color: var(--accent); }

.fc-rate-easy { border-color: rgba(59,130,246,.3); }
.fc-rate-easy:hover { background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.6); }
.fc-rate-easy .fc-rate-label { color: #3B82F6; }

/* Keyboard hint badge */
.fc-kbd {
  font-size: 10px;
  font-weight: 600;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-dark);
  font-family: 'Courier New', monospace;
  font-style: normal;
}

/* ── Done / completion screen ────────────────────────────────────────────── */
#fc-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}
#fc-done.hidden { display: none; }

.fc-done-icon  { font-size: 56px; }
.fc-done-title { font-size: 22px; font-weight: 900; letter-spacing: -.4px; }
.fc-done-sub   { font-size: 14px; color: var(--text-muted); }
.fc-restart-btn  { margin-top: 4px; width: auto !important; padding: 12px 28px !important; }
.fc-continue-btn { width: auto !important; padding: 12px 28px !important; gap: 10px !important; }
.fc-continue-badge {
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
}

@media (min-width: 640px) {
  #flashcard-container { padding: 18px 24px 24px; }
  .fc-question { font-size: 21px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   PLAN TAB
   ══════════════════════════════════════════════════════════════════════════ */
#planer-container {
  flex: 1;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 14px 16px calc(var(--player-h) + 12px + env(safe-area-inset-bottom));
  gap: 10px;
}
#planer-container.plan-active { display: flex; }

/* Planer PDF row */
#plan-pdf-row { display: flex; flex-direction: column; gap: 6px; }
.plan-pdf-btn { width: 100%; }
.plan-pdf-status { font-size: 13px; color: var(--text-muted); }
.plan-pdf-status a { color: var(--accent); }

/* Summary strip */
.plan-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 2px;
}
.plan-sum-chip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}
.plan-sum-chip b { color: var(--text-gray); font-weight: 700; }

/* Day list */
#planer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Day rows */
.plan-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  transition: border-color .2s, background .2s;
}
.plan-row-done {
  background: rgba(79,166,90,.04);
  border-color: rgba(79,166,90,.2);
}

/* Day number badge */
.plan-num {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-muted);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 1px;
}
.plan-row-done .plan-num {
  background: var(--accent-dim);
  border-color: rgba(79,166,90,.3);
  color: var(--accent-mint);
}

/* Day body */
.plan-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.plan-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.plan-terms {
  font-size: 11.5px;
  color: var(--text-dark);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Chip row */
.plan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
  align-items: center;
}

/* Base chip */
.plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated);
  color: var(--text-dark);
  white-space: nowrap;
  font-family: var(--font);
  cursor: default;
  user-select: none;
}
.plan-chip-done {
  background: var(--accent-dim);
  border-color: rgba(79,166,90,.3);
  color: var(--accent-mint);
}
.plan-chip-na {
  opacity: .4;
}

/* Planer toggle button */
.plan-chip-planer {
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.plan-chip-planer:not(.plan-chip-done):hover {
  background: var(--bg-muted);
  border-color: var(--border-med);
  color: var(--text-gray);
}
.plan-chip-planer.plan-chip-done:hover {
  background: var(--danger-dim);
  border-color: rgba(239,68,68,.3);
  color: var(--danger);
}

/* Mobile: summary chips show emoji only; FC chip shows % */
.plan-sum-label { display: none; }
.fc-chip-frac   { display: none; }
.fc-chip-pct    { display: inline; }

@media (min-width: 540px) {
  .plan-sum-label { display: inline; }
  .fc-chip-frac   { display: inline; }
  .fc-chip-pct    { display: none; }
}

@media (min-width: 640px) {
  #planer-container { padding: 18px 24px calc(var(--player-h) + 16px + env(safe-area-inset-bottom)); gap: 10px; }
  .plan-title { font-size: 14px; }
  .plan-terms { font-size: 12px; -webkit-line-clamp: 3; }
}

/* ══════════════════════════════════════════════════════════════════════════
   MATERIALS TAB
   ══════════════════════════════════════════════════════════════════════════ */
#materials-container {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  gap: 20px;
}
#materials-container.mat-active { display: flex; }

/* Section */
.mat-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mat-section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.2px;
}
.mat-section-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: -4px;
}

/* CKE grid */
.mat-cke-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.mat-cke-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.mat-cke-card:hover {
  border-color: var(--border-med);
  background: var(--bg-elevated);
}
.mat-cke-year {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.5px;
}
.mat-cke-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dark);
  background: var(--bg-muted);
  border-radius: 999px;
  padding: 2px 8px;
  align-self: flex-start;
}
.mat-cke-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mat-cke-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.mat-cke-link:hover { color: var(--accent-mint); }
.mat-cke-link-icon {
  width: 18px; height: 18px;
  background: var(--accent-dim);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}
.mat-cke-soon {
  font-size: 11px;
  color: var(--text-dark);
  font-style: italic;
}

/* Divider */
.mat-divider {
  height: 1px;
  background: var(--border);
}

/* ── Plan ribbon ────────────────────────────────────────────────────────── */
.plan-ribbon {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 16px;
}
.ribbon-spacer { flex: 1; min-width: 0; }
.ribbon-tile {
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
}
.ribbon-tile.rt-side {
  flex: 1;
  min-width: 0;
  aspect-ratio: 1;
  padding: 6px 4px;
  gap: 4px;
}
.ribbon-tile.rt-center {
  flex: 2.5;
  min-width: 0;
  padding: 14px 12px;
  gap: 6px;
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 14px rgba(79,166,90,.4);
}
.ribbon-tile.rt-side:hover { border-color: var(--border-med); background: var(--bg-elevated); }
.ribbon-tile.rt-center:hover { filter: brightness(1.08); }
.ribbon-tile.rt-done {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.rt-day-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}
.rt-done .rt-day-num { color: var(--accent); }
.rt-center .rt-day-num { color: rgba(255,255,255,.8); font-size: 11px; }
.rt-day-label {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-muted);
  line-height: 1;
}
.rt-done .rt-day-label { color: var(--accent); }
.rt-center .rt-day-label { display: none; }
.rt-day-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* ── Day detail modal ────────────────────────────────────────────────────── */
.day-modal-sheet { gap: 14px; }
.day-modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.4;
}
.day-modal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.dm-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.dm-chip strong { color: var(--text); }

/* Tips list */
.mat-tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mat-tip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.mat-tip-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}
.mat-tip-body { display: flex; flex-direction: column; gap: 2px; }
.mat-tip-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.mat-tip-text {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Wellbeing cards */
.mat-wellbeing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mat-wb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mat-wb-icon { font-size: 24px; }
.mat-wb-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.mat-wb-text {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Task generator */
.mat-gen-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mat-gen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mat-gen-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.mat-gen-stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mat-gen-step {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: border-color .15s;
}
.mat-gen-step:hover:not(:disabled) { border-color: var(--border-med); }
.mat-gen-step:disabled { opacity: .35; cursor: default; }
.mat-gen-count {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
  min-width: 20px;
  text-align: center;
  letter-spacing: -.5px;
}
.mat-gen-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.mat-gen-btn:hover:not(:disabled) { opacity: .85; }
.mat-gen-btn:disabled { opacity: .5; cursor: default; }
.mat-gen-status {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
}
.mat-gen-status a { color: var(--accent); font-weight: 600; }
.mat-gen-status.error { color: #e74c3c; }

/* Task generator — mode toggle */
.mat-gen-mode-row {
  display: flex;
  gap: 8px;
}
.mat-gen-mode-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mat-gen-mode-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.mat-gen-day-select {
  flex: 1;
  min-width: 0;
  width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dashboard widgets */
.dash-widgets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.dash-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-widget-val {
  font-size: 30px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -1.5px;
  line-height: 1;
}
.dash-widget-total {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dark);
}
.dash-widget-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}
.dash-widget-bar {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}
.dash-widget-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .4s ease;
}

/* Plan progress rings */
#plan-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 0 8px;
}
.plan-rings-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}
.plan-ring-container {
  position: relative;
  width: 148px;
  height: 148px;
}
.plan-ring-svg {
  display: block;
  width: 148px;
  height: 148px;
}
.plan-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,.07);
  stroke-width: 10;
}
.plan-ring-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset .9s cubic-bezier(.4,0,.2,1);
}
.plan-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  pointer-events: none;
}
.plan-ring-pct {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1.5px;
}
.plan-ring-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 3px;
}
.plan-ring-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 3px;
}
.plan-ring-arc-focus { stroke: #60A5FA; }
.plan-ring-clickable { cursor: pointer; transition: opacity .15s; }
.plan-ring-clickable:hover { opacity: .75; }

.plan-goal-msg {
  font-size: 13px;
  font-weight: 700;
  color: #93C5FD;
  background: rgba(96,165,250,.1);
  border: 1px solid rgba(96,165,250,.25);
  border-radius: 999px;
  padding: 8px 18px;
  text-align: center;
  animation: goal-pop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes goal-pop {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* Tutorial overlay */
#tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 800;
  pointer-events: none;
}
#tutorial-overlay:not(.hidden) { pointer-events: auto; }

#tutorial-hl {
  position: fixed;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.78);
  z-index: 801;
  pointer-events: none;
  transition: top .28s ease, left .28s ease, width .28s ease, height .28s ease;
}

#tutorial-popup {
  position: fixed;
  z-index: 802;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-med);
  border-radius: 16px;
  padding: 20px 20px 16px;
  width: min(340px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  animation: tut-pop .22s ease;
}
@keyframes tut-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.tut-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tut-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}
.tut-counter {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dark);
}
.tut-body {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}
.tut-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
.tut-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.tut-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--border-med);
  transition: background .2s, width .2s;
}
.tut-dot.active {
  background: var(--accent);
  width: 16px;
}
.tut-skip-btn {
  font-size: 12px;
  color: var(--text-dark);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
}
.tut-skip-btn:hover { color: var(--text-muted); }
.tut-next-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.tut-next-btn:hover { opacity: .85; }

@media (min-width: 640px) {
  #materials-container { padding: 18px 24px calc(20px + env(safe-area-inset-bottom)); }
  .mat-cke-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .mat-wellbeing-grid { grid-template-columns: repeat(4, 1fr); }
  .mat-gen-card { max-width: 360px; }
  .mat-gen-btn { padding: 8px 14px; font-size: 12px; }
  .mat-gen-mode-btn { padding: 5px 8px; font-size: 11px; }
  .plan-ribbon { max-width: 520px; margin-left: auto; margin-right: auto; }
}

/* ══════════════════════════════════════════════════════════════════════════
   MATURA COUNTDOWN
   ══════════════════════════════════════════════════════════════════════════ */

.matura-countdown {
  background: linear-gradient(135deg, rgba(79,166,90,.13) 0%, rgba(79,166,90,.05) 100%);
  border: 1px solid rgba(79,166,90,.3);
  border-radius: 14px;
  padding: 14px 16px 16px;
  margin-bottom: 4px;
  text-align: center;
}
.matura-cd-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-mint);
  letter-spacing: .3px;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.matura-cd-units {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
}
.matura-cd-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
}
.matura-cd-val {
  font-size: 32px;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.matura-cd-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 3px;
}
.matura-cd-sep {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 14px;
  opacity: .6;
}
.matura-countdown.finished .matura-cd-units { display: none; }
.matura-countdown.finished .matura-cd-label {
  font-size: 15px;
  margin-bottom: 0;
  text-transform: none;
  color: var(--accent);
}

/* ══════════════════════════════════════════════════════════════════════════
   POMODORO
   ══════════════════════════════════════════════════════════════════════════ */

/* Clickable wellbeing card */
.pomo-card {
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pomo-card:hover { border-color: var(--border-med); background: var(--bg-elevated); }
.pomo-card-cta {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 6px;
}

/* Modal sheet overrides */
.pomo-sheet {
  align-items: center;
  gap: 18px;
}

/* Phase label */
.pomo-phase-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}

/* Ring */
.pomo-ring-container {
  position: relative;
  width: 180px;
  height: 180px;
}
.pomo-ring-svg {
  display: block;
  width: 180px;
  height: 180px;
}
.pomo-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,.07);
  stroke-width: 10;
}
.pomo-ring-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset .6s linear, stroke .3s ease;
}
.pomo-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}
.pomo-time {
  font-size: 46px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.pomo-cycle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Cycle dots */
.pomo-dots {
  display: flex;
  gap: 10px;
  align-items: center;
}
.pomo-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--bg-muted);
  border: 1.5px solid var(--border-soft);
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.pomo-dot-done {
  background: var(--accent);
  border-color: var(--accent);
}
.pomo-dot-active {
  background: transparent;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,166,90,.2);
}

/* Controls */
.pomo-controls {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}
.pomo-btn-secondary {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: rgba(255,255,255,.05);
  color: var(--text-gray);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s;
}
.pomo-btn-secondary:hover { background: rgba(255,255,255,.09); }
.pomo-btn-primary {
  flex: 2;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 0 20px rgba(79,166,90,.25);
  transition: background .15s, box-shadow .15s;
}
.pomo-btn-primary:hover { background: var(--accent-mint); box-shadow: var(--shadow-green); }

/* Stats row */
.pomo-stats-row {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  width: 100%;
  max-width: 280px;
}
.pomo-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.pomo-stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border-soft);
  margin: 0 12px;
}
.pomo-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
}
.pomo-stat-val {
  font-size: 20px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -.5px;
}

/* ══════════════════════════════════════════════════════════════════════════
   KOLOROWANKI CAROUSEL
   ══════════════════════════════════════════════════════════════════════════ */

.kol-carousel {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kol-viewport {
  flex: 1;
  overflow: hidden;
}
.kol-track {
  display: flex;
  gap: 10px;
  transition: transform .3s ease;
}
.kol-slide {
  flex: 0 0 130px;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
  border: 2px solid var(--border);
  transition: border-color .15s, transform .15s;
  user-select: none;
}
.kol-slide:hover { border-color: var(--accent); transform: scale(1.03); }
.kol-slide:active { transform: scale(.97); }
.kol-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.kol-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: 5px 4px;
}
.kol-arrow {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.kol-arrow:hover { background: var(--bg-elevated); }
.kol-arrow:disabled { opacity: .3; cursor: default; }
#kol-modal { align-items: center; padding: 24px; }

.kol-modal-sheet {
  position: relative;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 12px;
  max-width: min(92vw, 420px);
  display: flex;
  flex-direction: column;
}
.kol-modal-img {
  width: 100%;
  border-radius: 10px;
  display: block;
  object-fit: contain;
}
.kol-modal-dl {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 50px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(79,166,90,.5);
  transition: opacity .15s;
}
.kol-modal-dl:hover { opacity: .85; }
