/* ============================================================
   WORKOUT TRACKER — Complete Stylesheet
   Light/Dark/Device theme, mobile-first, premium fitness aesthetic
   ============================================================ */

/* --- CSS Custom Properties (non-color, shared) --- */
:root {
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --sidebar-width: 240px;
  --topbar-height: 56px;
  --bottomnav-height: 56px;

  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";

  --transition-fast: 150ms ease;
  --transition: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ============================================================
   THEME: DARK (default)
   ============================================================ */
:root,
[data-theme="dark"] {
  --accent: #00E5FF;
  --accent-rgb: 0, 229, 255;
  --accent-dim: rgba(0, 229, 255, 0.15);
  --accent-hover: rgba(0, 229, 255, 0.9);
  --accent-text: #00E5FF;

  --bg: #0a0a0a;
  --bg-card: #111111;
  --bg-input: #1a1a1a;
  --bg-elevated: #161616;
  --bg-hover: #1e1e1e;

  --text: #ffffff;
  --text-muted: #888888;
  --text-dim: #555555;

  --border: #333333;
  --border-focus: var(--accent);
  --separator: rgba(255, 255, 255, 0.04);

  --glass-bg: rgba(10, 10, 10, 0.85);
  --glass-bg-heavy: rgba(10, 10, 10, 0.75);
  --shadow-card: none;
  --shadow-dropdown: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 16px 64px rgba(0, 0, 0, 0.5);
  --shadow-toast: 0 4px 24px rgba(0, 0, 0, 0.3);

  --skeleton-shimmer: rgba(255, 255, 255, 0.04);
  --table-stripe: rgba(255, 255, 255, 0.015);
  --btn-google-bg: #ffffff;
  --btn-google-text: #333333;
  --btn-google-shadow: 0 4px 24px rgba(255, 255, 255, 0.1);

  --success-flash: rgba(34, 197, 94, 0.27);
  --color-scheme: dark;
}

/* ============================================================
   THEME: LIGHT
   ============================================================ */
[data-theme="light"] {
  --accent: #00E5FF;
  --accent-rgb: 0, 229, 255;
  --accent-dim: rgba(0, 229, 255, 0.12);
  --accent-hover: rgba(0, 200, 230, 0.95);
  --accent-text: #007a8a;

  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-input: #f0f0f2;
  --bg-elevated: #ffffff;
  --bg-hover: #eeeef0;

  --text: #1c1c1e;
  --text-muted: #6e6e73;
  --text-dim: #aeaeb2;

  --border: #d2d2d7;
  --border-focus: var(--accent);
  --separator: rgba(0, 0, 0, 0.06);

  --glass-bg: rgba(245, 245, 247, 0.8);
  --glass-bg-heavy: rgba(245, 245, 247, 0.75);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-dropdown: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-modal: 0 16px 64px rgba(0, 0, 0, 0.15);
  --shadow-toast: 0 4px 24px rgba(0, 0, 0, 0.1);

  --skeleton-shimmer: rgba(0, 0, 0, 0.04);
  --table-stripe: rgba(0, 0, 0, 0.02);
  --btn-google-bg: #ffffff;
  --btn-google-text: #333333;
  --btn-google-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);

  --success-flash: rgba(34, 197, 94, 0.2);
  --color-scheme: light;
}

/* ============================================================
   THEME: DEVICE (system preference)
   Defaults to dark, flips to light if OS prefers light
   ============================================================ */
@media (prefers-color-scheme: light) {
  [data-theme="device"] {
    --accent: #00E5FF;
    --accent-rgb: 0, 229, 255;
    --accent-dim: rgba(0, 229, 255, 0.12);
    --accent-hover: rgba(0, 200, 230, 0.95);
    --accent-text: #007a8a;

    --bg: #f5f5f7;
    --bg-card: #ffffff;
    --bg-input: #f0f0f2;
    --bg-elevated: #ffffff;
    --bg-hover: #eeeef0;

    --text: #1c1c1e;
    --text-muted: #6e6e73;
    --text-dim: #aeaeb2;

    --border: #d2d2d7;
    --border-focus: var(--accent);
    --separator: rgba(0, 0, 0, 0.06);

    --glass-bg: rgba(245, 245, 247, 0.8);
    --glass-bg-heavy: rgba(245, 245, 247, 0.75);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-dropdown: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-modal: 0 16px 64px rgba(0, 0, 0, 0.15);
    --shadow-toast: 0 4px 24px rgba(0, 0, 0, 0.1);

    --skeleton-shimmer: rgba(0, 0, 0, 0.04);
    --table-stripe: rgba(0, 0, 0, 0.02);
    --btn-google-bg: #ffffff;
    --btn-google-text: #333333;
    --btn-google-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);

    --success-flash: rgba(34, 197, 94, 0.2);
    --color-scheme: light;
  }
}

/* ============================================================
   THEME TRANSITION (smooth switch between themes)
   ============================================================ */
html {
  color-scheme: var(--color-scheme, dark);
}

body,
.top-bar,
.bottom-nav,
.sidebar,
.card,
.stat-card,
.modal,
.toast,
.user-dropdown,
.form-input,
.form-select {
  transition: background-color var(--transition), color var(--transition),
    border-color var(--transition), box-shadow var(--transition);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

[hidden] {
  display: none !important;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
}

.login-container {
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.login-logo {
  margin-bottom: 48px;
}

.login-logo svg {
  margin: 0 auto 16px;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

.btn-google-signin {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 28px;
  background: var(--btn-google-bg);
  color: var(--btn-google-text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-google-signin:hover {
  transform: translateY(-1px);
  box-shadow: var(--btn-google-shadow);
}

.btn-google-signin:active {
  transform: translateY(0);
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* --- Top Bar --- */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.top-bar-logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.top-bar-right {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  transition: background var(--transition-fast);
}

.user-menu-trigger:hover {
  background: var(--bg-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-input);
}

.user-menu-caret {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.user-menu-trigger[aria-expanded="true"] .user-menu-caret {
  transform: rotate(180deg);
}

/* User Dropdown */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-dropdown);
  overflow: hidden;
  z-index: 200;
}

.user-dropdown-info {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-display-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.user-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ============================================================
   SIDEBAR NAVIGATION (Desktop)
   ============================================================ */
.sidebar {
  display: none;
}

@media (min-width: 768px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    z-index: 90;
    overflow-y: auto;
  }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.925rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-item.active:hover {
  background: var(--accent-dim);
  color: var(--accent-text);
}

.nav-icon {
  flex-shrink: 0;
}

/* ============================================================
   BOTTOM NAVIGATION (Mobile)
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 4px;
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: color var(--transition-fast);
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.bottom-nav-item .nav-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.bottom-nav-item.active {
  color: var(--accent);
  font-weight: 600;
}

.bottom-nav-item:hover {
  color: var(--text-muted);
}

.bottom-nav-item.active:hover {
  color: var(--accent-text);
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-content {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: none;
  padding: calc(var(--topbar-height) + env(safe-area-inset-top, 0px) + 16px) 12px calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px) + 16px);
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .main-content {
    margin-left: var(--sidebar-width);
    padding: calc(var(--topbar-height) + 24px) 32px 32px;
    width: calc(100% - var(--sidebar-width));
    max-width: none;
  }
}

/* --- Calendar Day Circles --- */
.cal-day {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  cursor: default;
  transition: all 0.2s;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

.cal-day.cal-workout {
  border: 2px solid var(--accent);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.cal-day.cal-today {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

/* --- Views --- */
.view {
  display: none;
  animation: viewFadeIn var(--transition-slow) ease forwards;
}

.view.active {
  display: block;
}

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

.view-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-card);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent-text);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-unit {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ============================================================
   SKELETON / LOADING STATE
   ============================================================ */
.skeleton {
  position: relative;
  overflow: hidden;
  color: transparent !important;
  background: var(--bg-hover);
  border-radius: var(--radius-xs);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--skeleton-shimmer) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

/* ============================================================
   BAR CHART (Dashboard - Yearly Activity)
   ============================================================ */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 140px;
}

@media (min-width: 768px) {
  .bar-chart-bars {
    height: 180px;
    gap: 10px;
  }
}

.bar-chart-bars .bar {
  flex: 1;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height var(--transition-slow) ease;
  position: relative;
  cursor: pointer;
}

.bar-chart-bars .bar:hover {
  opacity: 0.85;
}

.bar-chart-bars .bar::after {
  content: attr(data-value);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.bar-chart-bars .bar:hover::after {
  opacity: 1;
}

.bar-chart-labels {
  display: flex;
  gap: 6px;
}

@media (min-width: 768px) {
  .bar-chart-labels {
    gap: 10px;
  }
}

.bar-chart-labels span {
  flex: 1;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ============================================================
   CATEGORY DISTRIBUTION (Dashboard)
   ============================================================ */
.category-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.category-bar-label span:first-child {
  font-weight: 500;
}

.category-bar-label span:last-child {
  color: var(--text-muted);
}

.category-bar-track {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width var(--transition-slow) ease;
}

/* ============================================================
   CALENDAR (Dashboard & History)
   ============================================================ */
.calendar {
  width: 100%;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: default;
}

.calendar-day.empty {
  visibility: hidden;
}

.calendar-day.today {
  border: 1px solid var(--text-dim);
  color: var(--text);
  font-weight: 600;
}

.calendar-day.has-workout {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  cursor: pointer;
}

.calendar-day.has-workout:hover {
  opacity: 0.85;
}

.calendar-day.selected {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

/* Mini calendar in History */
.calendar-mini .calendar-day {
  font-size: 0.75rem;
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-label-sm {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.form-input::placeholder {
  color: var(--text-dim);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Date input — constrain iOS native picker width */
input[type="date"] {
  color-scheme: var(--color-scheme, dark);
  max-width: 100%;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}

input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  overflow: hidden;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 2px solid var(--border);
  border-radius: 50%;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast), opacity var(--transition-fast);
}

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

.btn-accent {
  background: var(--accent);
  color: var(--bg);
}

.btn-accent:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 16px rgba(var(--accent-rgb), 0.25);
}

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

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-danger {
  background: #ff4444;
  color: #fff;
}

.btn-danger:hover {
  background: #e63939;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ============================================================
   LOG WORKOUT VIEW
   ============================================================ */
.workout-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.workout-date-picker {
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workout-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  min-width: 180px;
  box-shadow: var(--shadow-card);
}

.timer-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.timer-display {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--accent-text);
  line-height: 1;
}

.timer-controls {
  display: flex;
  gap: 8px;
}

/* Exercise Selector */
.exercise-selector {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.set-entry {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: flex-end;
}

@media (max-width: 480px) {
  .set-entry {
    grid-template-columns: 1fr 1fr;
  }

  .set-entry .btn {
    grid-column: 1 / -1;
  }
}

/* Workout Sets List */
.workout-sets-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.workout-exercise-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workout-exercise-group-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-text);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.workout-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--separator);
}

.workout-set-info {
  display: flex;
  gap: 16px;
  color: var(--text-muted);
}

.workout-set-info strong {
  color: var(--text);
}

.btn-delete-set {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  font-size: 1.1rem;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-delete-set:hover {
  background: rgba(255, 68, 68, 0.15);
  color: #ff4444;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 24px 16px;
  font-size: 0.9rem;
}

/* ============================================================
   HISTORY VIEW
   ============================================================ */
.history-month-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.history-month-label {
  font-size: 1.05rem;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

.history-detail {
  margin-top: 16px;
}

.history-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.history-detail-actions {
  display: flex;
  gap: 8px;
}

/* Mobile: Card Layout */
.history-cards .history-exercise-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
}

.history-exercise-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent-text);
  margin-bottom: 8px;
}

.history-exercise-card-set {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--separator);
}

.history-exercise-card-set:last-child {
  border-bottom: none;
}

/* Desktop: Table Layout */
.history-table-wrap {
  display: none;
  overflow-x: auto;
}

@media (min-width: 768px) {
  .history-cards {
    display: none;
  }

  .history-table-wrap {
    display: block;
  }
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.history-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.history-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--separator);
}

.history-table tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.history-table tbody tr:hover {
  background: var(--bg-hover);
}

/* Data-editable cells */
[data-editable] {
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: var(--text-dim);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-radius: 3px;
  padding: 2px 4px;
  margin: -2px -4px;
}

[data-editable]:hover {
  background: var(--accent-dim);
  color: var(--accent-text);
  text-decoration-color: var(--accent-text);
}

.history-table .actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}

/* ============================================================
   EXERCISES VIEW
   ============================================================ */
.exercises-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exercise-category {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.exercise-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.exercise-category-header:hover {
  background: var(--bg-hover);
}

.exercise-category-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.exercise-category-chevron {
  color: var(--text-dim);
  transition: transform var(--transition);
}

.exercise-category.expanded .exercise-category-chevron {
  transform: rotate(180deg);
}

.exercise-category-actions {
  display: flex;
  gap: 4px;
}

.exercise-category-body {
  display: none;
  padding: 0 16px 14px;
}

.exercise-category.expanded .exercise-category-body {
  display: block;
}

.exercise-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--separator);
  font-size: 0.9rem;
}

.exercise-item:last-child {
  border-bottom: none;
}

.exercise-item-actions {
  display: flex;
  gap: 4px;
}

.btn-add-exercise {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  transition: opacity var(--transition-fast);
}

.btn-add-exercise:hover {
  opacity: 0.8;
}

/* Inline forms */
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 4px;
}

.inline-form .form-input {
  flex: 1;
}

/* ============================================================
   SETTINGS VIEW
   ============================================================ */

/* Theme Toggle */
.theme-toggle {
  display: flex;
  gap: 8px;
}

.theme-toggle-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast),
    color var(--transition-fast), box-shadow var(--transition-fast);
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.theme-toggle-btn.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent-text);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.2);
}

.theme-toggle-btn svg {
  flex-shrink: 0;
}

/* Color Picker */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  cursor: pointer;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}

.color-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.color-input {
  width: 36px;
  height: 36px;
}

/* Data management */
.data-management {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modalOverlayIn var(--transition) ease;
}

@keyframes modalOverlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: modalSlideIn var(--transition) ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  color: var(--text-dim);
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 0 20px 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  width: 100%;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-toast);
  font-size: 0.9rem;
  pointer-events: auto;
  animation: toastIn var(--transition) ease forwards;
}

.toast.toast-out {
  animation: toastOut var(--transition) ease forwards;
}

.toast-success {
  border-left: 3px solid var(--accent);
}

.toast-error {
  border-left: 3px solid #ff4444;
}

.toast-info {
  border-left: 3px solid #4488ff;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-message {
  flex: 1;
}

.toast-close {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.toast-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-accent {
  color: var(--accent-text);
}

.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

.mt-sm {
  margin-top: 8px;
}

.mt-md {
  margin-top: 16px;
}

.mt-lg {
  margin-top: 24px;
}

.mb-sm {
  margin-bottom: 8px;
}

.mb-md {
  margin-bottom: 16px;
}

.gap-sm {
  gap: 8px;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================
   RESPONSIVE FINE-TUNING
   ============================================================ */
@media (max-width: 480px) {
  .view-title {
    font-size: 1.25rem;
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .timer-display {
    font-size: 1.6rem;
  }

  .card {
    padding: 16px;
  }

  .workout-timer {
    width: 100%;
    padding: 14px 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    gap: 16px;
  }

  .bar-chart-bars {
    height: 220px;
  }
}

/* ============================================================
   PRINT (hidden for now, no printing needed)
   ============================================================ */
@media print {
  .top-bar,
  .sidebar,
  .bottom-nav,
  .toast-container {
    display: none !important;
  }

  .main-content {
    padding: 0;
    margin: 0;
  }

  body {
    background: #fff;
    color: #000;
  }
}
