﻿:root {
  --bg: #f6f1e7;
  --bg-soft: #fbf7f1;
  --surface: rgba(255, 250, 244, 0.9);
  --surface-strong: #fffdf9;
  --ink: #1f2a1f;
  --ink-soft: #5c665a;
  --line: rgba(32, 40, 31, 0.12);
  --accent: #ff7a2f;
  --accent-deep: #c65316;
  --accent-soft: rgba(255, 122, 47, 0.14);
  --success: #3d8a57;
  --shadow: 0 18px 48px rgba(49, 44, 32, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Assistant", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 157, 92, 0.24), transparent 32%),
    radial-gradient(circle at top right, rgba(72, 124, 90, 0.14), transparent 28%),
    linear-gradient(180deg, #f9f4ea 0%, #efe5d5 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  padding: 0.95rem 1rem;
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(255, 122, 47, 0.6);
  box-shadow: 0 0 0 4px rgba(255, 122, 47, 0.12);
}

label {
  display: grid;
  gap: 0.45rem;
}

label span {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem calc(6rem + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0 1.35rem;
}

.topbar h1 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.05;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--accent-deep);
  font-weight: 800;
}

.content {
  display: grid;
  gap: 1rem;
}

.view {
  display: none;
  gap: 1rem;
}

.view.active {
  display: grid;
}

.hero-card,
.panel,
.stat-card,
.template-card,
.exercise-card,
.nutrition-entry,
.measurement-entry,
.history-entry {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card,
.panel {
  border-radius: var(--radius-xl);
  padding: 1.15rem;
}

.hero-card {
  display: grid;
  gap: 1rem;
  background:
    linear-gradient(145deg, rgba(255, 125, 48, 0.96), rgba(184, 78, 16, 0.92)),
    var(--surface);
  color: white;
}

.hero-card h2 {
  margin: 0.2rem 0 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.1;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
}

.card-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
}

.stat-card {
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.stat-card span {
  display: block;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.stat-card strong {
  font-size: 1.45rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-header.compact {
  margin-bottom: 0.75rem;
}

.panel-header h3,
.panel-header h4 {
  margin: 0;
}

.sticky-panel {
  position: sticky;
  top: 0.5rem;
  z-index: 3;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.quick-action,
.tab-button,
.nav-button,
.primary-button,
.ghost-button {
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1rem;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.quick-action,
.tab-button,
.nav-button,
.ghost-button {
  background: var(--surface-strong);
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-button {
  background: var(--ink);
  color: white;
}

.primary-button.small,
.ghost-button.small {
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
}

.quick-action:hover,
.tab-button:hover,
.nav-button:hover,
.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.tab-button.active,
.nav-button.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.stack {
  display: grid;
  gap: 0.8rem;
}

.grid-two,
.grid-three,
.timer-grid,
.set-row {
  display: grid;
  gap: 0.75rem;
}

.grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.template-card,
.exercise-card,
.nutrition-entry,
.measurement-entry,
.history-entry {
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.template-card {
  display: grid;
  gap: 0.85rem;
}

.template-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-pill {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.84rem;
  font-weight: 700;
}

.exercise-builder-item {
  padding: 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
}

.timer-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.timer-card {
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  display: grid;
  gap: 0.45rem;
}

.timer-card strong {
  font-size: clamp(1.55rem, 3vw, 2rem);
}

.timer-card-rest {
  background: rgba(61, 138, 87, 0.1);
}

.timer-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.exercise-card {
  display: grid;
  gap: 0.9rem;
}

.exercise-topline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.exercise-topline h4 {
  margin: 0;
}

.exercise-subtitle {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.set-row {
  grid-template-columns: 68px repeat(2, minmax(0, 1fr)) minmax(110px, 1.4fr) 78px;
  align-items: end;
  padding: 0.8rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.set-row.completed {
  border-color: rgba(61, 138, 87, 0.4);
  background: rgba(61, 138, 87, 0.08);
}

.set-row-label {
  font-weight: 800;
}

.checkbox-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 0.35rem;
}

.checkbox-wrap input {
  width: 20px;
  height: 20px;
}

.note-badge {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.empty-state {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(32, 40, 31, 0.24);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.54);
}

.history-tabs {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.entry-grid {
  display: grid;
  gap: 0.45rem;
}

.entry-grid strong {
  display: block;
}

.bottom-nav {
  position: fixed;
  right: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(50%);
  width: min(720px, calc(100% - 1rem));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 999px;
  background: rgba(255, 248, 239, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 45px rgba(36, 29, 19, 0.16);
  backdrop-filter: blur(16px);
}

.bottom-nav .nav-button {
  padding: 0.8rem 0.5rem;
  border-radius: 999px;
}

@media (max-width: 720px) {
  .timer-grid,
  .grid-three {
    grid-template-columns: 1fr;
  }

  .set-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .set-row .set-row-label,
  .set-row .checkbox-wrap {
    grid-column: span 1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 0.85rem;
  }

  .grid-two,
  .quick-actions,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .exercise-topline,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.3rem;
    padding: 0.35rem;
  }

  .bottom-nav .nav-button {
    font-size: 0.82rem;
    padding: 0.72rem 0.25rem;
  }
}

#active-workout-panel {
  scroll-margin-top: 1rem;
}

/* ── Auth overlay ─────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow-y: auto;
  padding: 2rem 1rem 5rem;
  background:
    radial-gradient(circle at top left,  rgba(255, 157, 92, 0.24), transparent 32%),
    radial-gradient(circle at top right, rgba(72, 124, 90, 0.14),  transparent 28%),
    linear-gradient(180deg, #f9f4ea 0%, #efe5d5 100%);
}

.auth-overlay-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.auth-header {
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.auth-error {
  color: #b53b2a;
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  background: rgba(181, 59, 42, 0.08);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(181, 59, 42, 0.18);
}

.auth-switch {
  text-align: center;
  margin-top: 1rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ── Topbar actions ───────────────────────────────────────────────────────── */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.topbar-username {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
  white-space: nowrap;
}


/* ── Charts ───────────────────────────────────────────────────────────────── */
.charts-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.charts-container.hidden {
  display: none;
}

.chart-wrap {
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  padding: 1rem 1rem 0.75rem;
  border: 1px solid var(--line);
  position: relative;
  height: 240px;
}

.chart-title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.chart-wrap canvas {
  max-height: 180px;
}

/* ── Goals ────────────────────────────────────────────────────────────────── */
.goal-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.goal-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
}

.goal-label {
  font-weight: 600;
  color: var(--ink);
}

.goal-values {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.goal-sep {
  color: var(--ink-soft);
  opacity: 0.7;
}

.goal-bar-track {
  height: 8px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.goal-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.goal-bar-fill.done {
  background: var(--success);
}

/* ── Progress photos ──────────────────────────────────────────────────────── */
.photo-preview,
.progress-photo {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
  background: var(--line);
}

.photo-preview.hidden {
  display: none;
}

input[type="file"] {
  padding: 0.45rem 0.5rem;
  font-size: 0.9rem;
}

/* ── Backup panel ─────────────────────────────────────────────────────────── */
.backup-hint {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

#import-label input[type="file"] {
  display: none;
}
