@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  --ink: #121820;
  --slate: #1a2332;
  --slate-2: #243044;
  --mist: #e8eef4;
  --paper: #f4f7fa;
  --line: rgba(18, 24, 32, 0.08);
  --muted: #5c6b7a;
  --copper: #c8924a;
  --copper-deep: #a6722f;
  --sea: #2f6f7e;
  --sea-soft: #d5e8ec;
  --good: #2f6b4f;
  --danger: #9b3b2e;
  --shadow: 0 12px 40px rgba(18, 24, 32, 0.12);
  --radius: 18px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-synthesis: none;
}

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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(200, 146, 74, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(47, 111, 126, 0.16), transparent 50%),
    linear-gradient(180deg, #eef3f7 0%, var(--paper) 40%, #e7eef3 100%);
  background-attachment: fixed;
  line-height: 1.45;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
}

.screen {
  display: none;
  padding: calc(16px + var(--safe-top)) 16px 24px;
  animation: rise 0.35s ease;
}

.screen.active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Brand / Home ---------- */
.hero {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  padding: 28px 22px 24px;
  color: #f3f6f8;
  background:
    linear-gradient(145deg, rgba(200, 146, 74, 0.2), transparent 40%),
    linear-gradient(180deg, #1a2332 0%, #121820 100%);
  box-shadow: var(--shadow);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 80% 20%, rgba(47, 111, 126, 0.35), transparent 40%),
    repeating-linear-gradient(
      -18deg,
      transparent,
      transparent 14px,
      rgba(255, 255, 255, 0.02) 14px,
      rgba(255, 255, 255, 0.02) 15px
    );
  pointer-events: none;
}

.hero > * {
  position: relative;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
}

.brand-mark svg {
  width: 36px;
  height: 36px;
}

.brand-mark span {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 2.4rem;
  letter-spacing: 0.04em;
  line-height: 1;
}

.hero-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(243, 246, 248, 0.55);
  margin-bottom: 8px;
}

.hero h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2rem, 8vw, 2.55rem);
  line-height: 1.05;
  max-width: 12ch;
}

.hero h1 em {
  font-style: italic;
  color: var(--copper);
}

.hero-sub {
  margin-top: 10px;
  color: rgba(243, 246, 248, 0.7);
  font-size: 0.95rem;
  max-width: 28ch;
}

.today-card {
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 24px rgba(18, 24, 32, 0.06);
}

.today-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sea);
  background: var(--sea-soft);
  padding: 6px 10px;
  border-radius: 999px;
}

.pill.copper {
  color: var(--copper-deep);
  background: rgba(200, 146, 74, 0.18);
}

.time-badge {
  font-weight: 700;
  color: var(--slate);
  font-size: 0.95rem;
}

.today-card h2 {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.today-card p {
  color: var(--muted);
  font-size: 0.92rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
}

.btn-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.btn-row.day-actions {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.hint-line {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.workout-card {
  cursor: default;
}

.workout-card .card-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.workout-card .card-actions .btn {
  min-height: 42px;
  font-size: 0.85rem;
  padding: 0 8px;
}

.workout-card .day-date {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

.btn-primary {
  background: var(--slate);
  color: #f5f7f9;
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  min-height: 40px;
}

.btn-block {
  width: 100%;
}

.section {
  margin-top: 22px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.section-head h3 {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.section-meta {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--slate);
  font-variant-numeric: tabular-nums;
}

.week-progress-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.week-progress-card.accent {
  background: linear-gradient(160deg, #1a2332 0%, #243044 100%);
  border-color: transparent;
  color: #eef3f7;
  margin-bottom: 8px;
}

.week-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.week-progress-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(238, 243, 247, 0.55);
  margin-bottom: 4px;
}

.week-progress-range {
  font-size: 0.95rem;
  color: rgba(238, 243, 247, 0.85);
}

.week-progress-score {
  font-size: 1.5rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--copper);
}

.week-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(18, 24, 32, 0.08);
  overflow: hidden;
  margin-bottom: 12px;
}

.week-progress-card.accent .week-progress-bar {
  background: rgba(255, 255, 255, 0.12);
}

.week-progress-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sea), var(--copper));
  transition: width 0.35s ease;
}

.week-dots {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.week-dot {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(238, 243, 247, 0.45);
}

.week-dot i {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.week-dot.done i {
  background: var(--copper);
  border-color: transparent;
}

.week-dot.today span {
  color: #fff;
}

.week-history {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.week-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.week-row.current {
  border-color: rgba(200, 146, 74, 0.55);
  background: rgba(200, 146, 74, 0.1);
}

.week-row.future .week-row-label,
.week-row.future .week-row-score {
  color: var(--muted);
}

.week-row-label strong {
  display: block;
  font-size: 0.92rem;
}

.week-row-label span {
  font-size: 0.78rem;
  color: var(--muted);
}

.week-row-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--slate);
  white-space: nowrap;
}

.week-row-mini {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.week-row-mini b {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d5dde5;
}

.week-row-mini b.on {
  background: var(--copper);
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-chip {
  aspect-ratio: 1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}

.day-chip strong {
  font-size: 0.95rem;
  color: var(--ink);
  font-weight: 700;
}

.day-chip.today {
  background: var(--slate);
  color: rgba(255, 255, 255, 0.7);
  border-color: transparent;
}

.day-chip.today strong {
  color: #fff;
}

.day-chip.done {
  outline: 2px solid var(--copper);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 10px;
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  color: var(--slate);
}

.stat span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.principle-list {
  display: grid;
  gap: 8px;
}

.principle {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

.principle h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.principle p {
  font-size: 0.88rem;
  color: var(--muted);
}

/* ---------- Week / Library / Settings ---------- */
.page-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 2rem;
  margin-bottom: 6px;
}

.page-sub {
  color: var(--muted);
  margin-bottom: 18px;
  font-size: 0.95rem;
}

.card-list {
  display: grid;
  gap: 10px;
}

.workout-card {
  text-align: left;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  width: 100%;
}

.workout-card.done {
  border-color: rgba(200, 146, 74, 0.45);
}

.workout-card .top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.workout-card h3 {
  font-size: 1.1rem;
}

.workout-card p {
  color: var(--muted);
  font-size: 0.88rem;
}

.eq-toggles {
  display: grid;
  gap: 8px;
}

.eq-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

.eq-toggle .label strong {
  display: block;
  font-size: 0.98rem;
}

.eq-toggle .label span {
  font-size: 0.82rem;
  color: var(--muted);
}

.switch {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #c9d2da;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.eq-toggle.on .switch {
  background: var(--sea);
}

.eq-toggle.on .switch::after {
  transform: translateX(20px);
}

.install-card {
  margin-top: 18px;
  background: linear-gradient(160deg, var(--slate) 0%, #243044 100%);
  color: #eef3f7;
  border-radius: 18px;
  padding: 18px;
}

.install-card h3 {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.install-card ol {
  margin: 10px 0 0 1.1rem;
  color: rgba(238, 243, 247, 0.78);
  font-size: 0.9rem;
}

.install-card li {
  margin-bottom: 6px;
}

.prog-list {
  display: grid;
  gap: 8px;
}

.prog-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.prog-row strong {
  color: var(--copper-deep);
  font-size: 0.85rem;
}

.prog-row span {
  font-size: 0.88rem;
  color: var(--muted);
}

.library-item {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}

.library-item .meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.library-item h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.library-item p {
  font-size: 0.88rem;
  color: var(--muted);
}

.library-item .modify {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--copper-deep);
  font-style: italic;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.filter-chip.active {
  background: var(--slate);
  color: #fff;
  border-color: transparent;
}

/* ---------- Workout player ---------- */
.player {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--slate);
  color: #eef3f7;
  display: none;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
}

.player.open {
  display: flex;
  animation: rise 0.3s ease;
}

.player-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.player-top .close,
.player-top .skip {
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  color: rgba(238, 243, 247, 0.8);
  font-weight: 600;
}

.player-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

.player-progress > span {
  display: block;
  height: 100%;
  background: var(--copper);
  width: 0%;
  transition: width 0.3s ease;
}

.phase-label {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(238, 243, 247, 0.5);
  margin-bottom: 8px;
}

.player h2 {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.8rem, 7vw, 2.3rem);
  line-height: 1.1;
  margin-bottom: 8px;
}

.dose-line {
  font-size: 1.05rem;
  color: var(--copper);
  font-weight: 600;
  margin-bottom: 14px;
}

.cue {
  color: rgba(238, 243, 247, 0.78);
  font-size: 1rem;
  line-height: 1.55;
  flex: 1;
}

.modify-line {
  margin-top: 12px;
  font-size: 0.88rem;
  color: rgba(200, 146, 74, 0.9);
  font-style: italic;
}

.timer-ring {
  margin: 18px auto;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, #1a2332 62%, transparent 63%),
    conic-gradient(var(--copper) var(--p, 0%), rgba(255, 255, 255, 0.12) 0);
}

.timer-ring strong {
  font-size: 2.6rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.player-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.player-actions .btn {
  min-height: 52px;
}

.player-actions .btn-primary {
  background: var(--copper);
  color: var(--ink);
}

.player-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #eef3f7;
}

.rest-banner {
  display: none;
  text-align: center;
  margin-top: 8px;
  color: rgba(238, 243, 247, 0.6);
  font-size: 0.85rem;
}

.rest-banner.show {
  display: block;
}

.complete-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

.complete-panel.show {
  display: flex;
}

.complete-panel h2 {
  font-size: 2.4rem;
}

.complete-panel p {
  color: rgba(238, 243, 247, 0.7);
}

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 8px 10px var(--safe-bottom);
  background: rgba(244, 247, 250, 0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 20;
}

.nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 12px;
}

.nav button svg {
  width: 22px;
  height: 22px;
}

.nav button.active {
  color: var(--slate);
}

.nav button.active svg {
  stroke: var(--copper-deep);
}

.hidden {
  display: none !important;
}

@media (min-width: 480px) {
  body {
    padding-bottom: calc(var(--nav-h) + 24px);
  }
}
