:root {
  --bg: #0e0f13;
  --surface: #171922;
  --surface-2: #1f2230;
  --text: #f3f4f7;
  --muted: #9aa1ad;
  --accent: #ff5e3a;
  --accent-2: #ff8a5b;
  --radius: 18px;
  --gap: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 14px;
  background: rgba(14, 15, 19, 0.72);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.app-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.back-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 2px;
}

/* Views */
.view {
  padding: 20px 20px 60px;
  max-width: 1100px;
  margin: 0 auto;
}

/* Library */
.category { margin-bottom: 30px; }
.category-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 14px 2px;
  font-weight: 700;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--gap);
}
.card {
  appearance: none;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--surface);
  color: inherit;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:active { transform: scale(0.98); }
@media (hover: hover) {
  .card:hover { border-color: rgba(255, 255, 255, 0.16); }
}
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.play-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: #fff;
  padding-left: 2px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 14px rgba(255, 94, 58, 0.45);
}
.card-body { padding: 13px 14px 15px; }
.card-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Player */
.player-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  margin-bottom: 18px;
}
.player-wrap video {
  width: 100%;
  display: block;
  max-height: 70vh;
  background: #000;
}
.player-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.player-cat {
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 12px;
  font-size: 14px;
}
.player-view .chips { margin-bottom: 6px; }
.notes { margin-top: 18px; }
.notes p {
  color: #d7dae1;
  line-height: 1.6;
  font-size: 16px;
  margin: 0 0 14px;
}

.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* Today card */
.today-card {
  border-radius: var(--radius);
  padding: 22px 22px 24px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 94, 58, 0.22), transparent 60%),
    var(--surface);
}
.today-card.t-yoga {
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(110, 168, 255, 0.22), transparent 60%),
    var(--surface);
}
.today-card.t-rest {
  background: var(--surface);
}
.today-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}
.today-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.today-note { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.today-sub { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.today-start {
  appearance: none;
  border: 0;
  cursor: pointer;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(255, 94, 58, 0.35);
}
.today-start:active { transform: scale(0.98); }

/* Week strip */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
  margin-bottom: 30px;
}
.week-cell {
  appearance: none;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}
.week-cell .wk-dow { font-size: 11px; color: var(--muted); font-weight: 700; }
.week-cell .wk-type { font-size: 12px; font-weight: 700; }
.week-cell.t-yoga .wk-type { color: #6ea8ff; }
.week-cell.t-rest .wk-type { color: var(--muted); }
.week-cell.t-gym .wk-type { color: var(--accent); }
.week-cell.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.week-cell .wk-check {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 10px;
  color: #34d27b;
  font-weight: 800;
}
.browse-head {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 16px 2px;
  font-weight: 700;
}

/* YouTube form demo */
.demo-wrap { margin-top: 22px; }
.demo-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius);
  background: #000;
  display: block;
}
.ghost-btn.full { width: 100%; }

.player-wrap .yt-main {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
  background: #000;
}

/* Top-right nav */
.nav-btn {
  margin-left: auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.nav-btn:active { transform: scale(0.97); }

/* Category header row */
.cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 14px;
}
.cat-head .category-title { margin: 0; }
.finish-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(255, 94, 58, 0.35);
}
.finish-btn:active { transform: scale(0.97); }

/* Done badge on a card */
.done-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: #06210f;
  background: #34d27b;
  box-shadow: 0 3px 10px rgba(52, 210, 123, 0.45);
}

/* Log panel (player) */
.log-panel {
  margin-top: 26px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 18px;
}
.log-title { margin: 0 0 14px; font-size: 17px; font-weight: 700; }
.field-label {
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.field-label.first { margin-top: 0; }
.score-row { display: flex; flex-wrap: wrap; gap: 8px; }
.score-btn {
  appearance: none;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.score-btn.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(255, 94, 58, 0.4);
}
.note-input {
  width: 100%;
  margin-top: 6px;
  min-height: 64px;
  resize: vertical;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 12px;
}
.note-input::placeholder { color: #6b7280; }
.primary-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  margin-top: 18px;
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(255, 94, 58, 0.35);
}
.primary-btn:active { transform: scale(0.99); }
.ghost-btn {
  appearance: none;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 16px;
  font-weight: 600;
  padding: 14px;
  border-radius: 14px;
}

/* Today's logged entries inside the player */
.today-logs {
  margin-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 14px;
}
.today-logs h4 {
  margin: 0 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.today-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  color: #d7dae1;
  font-size: 15px;
}

/* History */
.day-group { margin-bottom: 26px; }
.day-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px 2px;
  font-weight: 700;
}
.log-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.log-item.session {
  border-color: rgba(255, 94, 58, 0.35);
  background: linear-gradient(180deg, rgba(255, 94, 58, 0.08), var(--surface));
}
.log-main { flex: 1; min-width: 0; }
.log-name { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.log-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.log-note { margin: 10px 0 0; color: #c3c8d2; font-size: 14px; line-height: 1.5; }
.del-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #6b7280;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.del-btn:hover { color: #ff6b6b; }

/* Modal sheet */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-sheet {
  width: 100%;
  max-width: 560px;
  background: var(--bg);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}
.modal-title { margin: 0 0 18px; font-size: 20px; font-weight: 800; }
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 22px;
}
.modal-actions .primary-btn,
.modal-actions .ghost-btn { margin-top: 0; }
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: 24px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #22252f;
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Sign-in screen */
.auth-box {
  max-width: 380px;
  margin: 40px auto 0;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.auth-title { margin: 0 0 8px; font-size: 22px; font-weight: 800; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.auth-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 13px 14px;
}
.auth-input::placeholder { color: #6b7280; }
.auth-msg { margin: 14px 0 0; color: var(--muted); font-size: 14px; min-height: 18px; }

/* Account footer in History */
.account-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.account-email { color: var(--muted); font-size: 14px; }
.ghost-btn.small {
  margin-left: auto;
  padding: 8px 14px;
  font-size: 14px;
}
