@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

/* =============================================
   Moveary — Design System
   Mobile-first (390px base), Light mode default
   ============================================= */

:root {
  /* Brand Palette Tokens */
  --c-orange: #FF9E20;
  --c-teal: #215E61;
  --c-dark: #1D2128;
  --c-gray-bg: #F4F2F2;

  /* Color Tokens */
  --c-bg: #F8F9FB;
  --c-surface: #FFFFFF;
  --c-surface-raised: #FFFFFF;
  --c-elevated: #FFFFFF;

  --c-primary: #B54708;
  --c-primary-hover: #923E07;
  --c-primary-subtle: #FFF7ED;
  --c-on-primary: #FFFFFF;

  --c-teal-subtle: rgba(33, 94, 97, 0.08);

  --c-success: #15803D;
  --c-success-subtle: #F0FDF4;
  --c-warning: #A16207;
  --c-warning-subtle: #FEFCE8;
  --c-danger: #DC2626;
  --c-danger-subtle: #FEF2F2;
  --c-info: #215E61;
  --c-info-subtle: rgba(33, 94, 97, 0.08);

  --c-text: #1D2128;
  --c-text-secondary: #475569;
  --c-text-tertiary: #64748B;
  --c-text-muted: #64748B;

  --c-border: #E2E8F0;
  --c-border-subtle: #F1F5F9;
  --c-divider: #F1F5F9;

  /* Spacing Scale (4px base) */
  --sp-1: 0.25rem;   /* 4px */
  --sp-2: 0.5rem;    /* 8px */
  --sp-3: 0.75rem;   /* 12px */
  --sp-4: 1rem;      /* 16px */
  --sp-5: 1.25rem;   /* 20px */
  --sp-6: 1.5rem;    /* 24px */
  --sp-8: 2rem;      /* 32px */
  --sp-10: 2.5rem;   /* 40px */
  --sp-12: 3rem;     /* 48px */

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

  /* Layout */
  --radius-sm: 0.375rem;   /* 6px */
  --radius-md: 0.5rem;     /* 8px */
  --radius-lg: 0.75rem;    /* 12px */
  --radius-xl: 1rem;       /* 16px */
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);

  /* Motion */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Z-index */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal: 400;
}

/* =============================================
   Base Reset
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  word-break: keep-all;
  overflow-wrap: break-word;
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  border: none;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

.btn-remove-set,
.btn-remove-exercise {
  min-width: 44px;
  min-height: 44px;
}

fieldset {
  min-width: 0;
  border: 0;
}

input, select, textarea {
  outline: none;
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

/* =============================================
   App Shell
   ============================================= */
.app-shell {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-sizing: border-box;
  box-shadow: 0 0 40px rgba(15, 23, 42, 0.05);
}

/* =============================================
   Header
   ============================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: blur(8px);
  width: 100%;
  box-sizing: border-box;
}

.app-logo {
  font-weight: var(--weight-extrabold);
  font-size: var(--text-lg);
  letter-spacing: -0.03em;
  color: var(--c-text);
}

.logout-form {
  display: inline;
}

.btn-text {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  color: var(--c-text-tertiary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.btn-text:hover,
.btn-text:active {
  color: var(--c-text-secondary);
  background: var(--c-border-subtle);
}

/* =============================================
   Main Content
   ============================================= */
.app-main {
  flex: 1;
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-4) + 72px);
  width: 100%;
  box-sizing: border-box;
}

.app-main--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =============================================
   Page Title / Greeting
   ============================================= */
.page {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.greeting {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: 1.3;
  color: var(--c-text);
  letter-spacing: -0.02em;
  text-wrap: balance;
  word-break: keep-all;
}

/* =============================================
   Cards
   ============================================= */
.card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--c-border-subtle);
  padding: var(--sp-4);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card--highlight {
  border: 2px solid var(--c-primary);
  background: var(--c-primary-subtle);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--c-text);
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-wrap: balance;
  word-break: keep-all;
}

/* =============================================
   Forms
   ============================================= */
.form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.field-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--c-text-secondary);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field input[type="datetime-local"],
.field select {
  height: 48px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field textarea {
  height: auto;
  min-height: 80px;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  resize: vertical;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--c-text-muted);
}

.field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  accent-color: var(--c-primary);
  cursor: pointer;
}

.field-error {
  font-size: var(--text-sm);
  color: var(--c-danger);
  font-weight: var(--weight-medium);
}

.field--inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

/* =============================================
   Buttons
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-md);
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  border: 1px solid transparent;
  gap: var(--sp-2);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--c-primary);
  color: var(--c-on-primary);
  box-shadow: 0 1px 3px rgba(249, 115, 22, 0.2);
}

.btn-primary:hover {
  background: var(--c-primary-hover);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn-secondary:hover {
  background: var(--c-bg);
  border-color: var(--c-text-muted);
}

.btn-danger {
  background: var(--c-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-ghost {
  background: transparent;
  color: var(--c-text-secondary);
}

.btn-ghost:hover {
  background: var(--c-border-subtle);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 44px;
  padding: 0 var(--sp-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.btn-group {
  display: flex;
  gap: var(--sp-2);
}

.btn-group .btn {
  flex: 1;
}

/* =============================================
   Lists
   ============================================= */
.list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.list-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.list-item:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-sm);
}

.list-title {
  font-weight: var(--weight-semibold);
  color: var(--c-text);
}

.list-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--c-text-tertiary);
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
}

.list-item--link {
  padding: 0;
  border: none;
  background: none;
}

.list-item--link > a {
  display: flex;
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  width: 100%;
}

/* =============================================
   Badges
   ============================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-success {
  background: var(--c-success-subtle);
  color: #166534;
}

.badge-warning {
  background: var(--c-warning-subtle);
  color: #854D0E;
}

.badge-danger {
  background: var(--c-danger-subtle);
  color: #991B1B;
}

.badge-info {
  background: var(--c-info-subtle);
  color: #1E40AF;
}

.badge-muted {
  background: var(--c-border-subtle);
  color: var(--c-text-tertiary);
}

/* =============================================
   Session / Stat Rows
   ============================================= */
.session-list,
.member-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.session-item,
.member-item {
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  transition: border-color var(--transition-fast);
}

.session-item:hover,
.member-item:hover {
  border-color: var(--c-primary);
}

.session-row,
.member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
}

.session-time {
  font-weight: var(--weight-bold);
  min-width: 3.5rem;
  color: var(--c-text);
}

.session-member {
  flex: 1;
  font-weight: var(--weight-medium);
}

.session-count {
  font-size: var(--text-sm);
  color: var(--c-text-tertiary);
}

.member-name {
  flex: 1;
  font-weight: var(--weight-semibold);
}

.member-remaining {
  font-weight: var(--weight-bold);
  color: var(--c-primary);
}

.member-remaining.is-muted {
  color: var(--c-text-tertiary);
  font-weight: var(--weight-normal);
}

.member-usage {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
}

/* =============================================
   Stats
   ============================================= */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--c-divider);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--c-text-tertiary);
  font-weight: var(--weight-medium);
}

.stat-value {
  font-weight: var(--weight-bold);
  color: var(--c-text);
}

.text-primary { color: var(--c-primary); }
.text-muted { color: var(--c-text-tertiary); }
.text-danger { color: var(--c-danger); }
.text-success { color: var(--c-success); }

/* =============================================
   Alerts
   ============================================= */
.alert {
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-align: center;
}

.alert-success {
  background: var(--c-success-subtle);
  color: #166534;
}

.alert-error {
  background: var(--c-danger-subtle);
  color: #991B1B;
}

.alert-warning {
  background: var(--c-warning-subtle);
  color: #854D0E;
}

/* =============================================
   Empty States
   ============================================= */
.empty {
  color: var(--c-text-tertiary);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--sp-8) 0;
}

/* =============================================
   Bottom Navigation
   ============================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  z-index: var(--z-fixed);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.04);
}

.bottom-nav-item {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 3px !important;
  height: 58px;
  padding: 4px 0 2px 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-tertiary);
  text-decoration: none !important;
  transition: color var(--transition-fast), transform var(--transition-fast);
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-icon {
  order: 1;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px;
  height: 24px;
  transition: transform var(--transition-fast);
  line-height: 1;
}

.bottom-nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2px;
  display: block;
}

.bottom-nav-label {
  order: 2;
  display: block !important;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.bottom-nav-item.is-active {
  color: var(--c-primary);
  font-weight: 700;
}

.bottom-nav-item.is-active .bottom-nav-label {
  font-weight: 700;
  color: var(--c-primary);
}

.bottom-nav-item.is-active .bottom-nav-icon {
  transform: translateY(-1px);
}

.bottom-nav-item.is-active .bottom-nav-icon svg {
  stroke-width: 2.25px;
}

.bottom-nav-item.is-active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2.5px;
  border-radius: 0 0 4px 4px;
  background: var(--c-primary);
}

.bottom-nav-item.is-center-home .bottom-nav-icon svg {
  width: 22px;
  height: 22px;
}

.bottom-nav-item.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* =============================================
   Auth Pages
   ============================================= */
.auth-card {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-4);
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-extrabold);
  margin-bottom: var(--sp-5);
  text-align: center;
  letter-spacing: -0.02em;
}

.auth-switch {
  margin-top: var(--sp-4);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--c-text-tertiary);
}

.auth-switch a {
  color: var(--c-primary);
  font-weight: var(--weight-semibold);
}

.auth-utility-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font-weight: var(--weight-medium);
}

.field-action-row {
  display: flex;
  gap: var(--sp-2);
  align-items: stretch;
}

.field-action-row > input {
  flex: 1;
  min-width: 0;
}

.terms-agreement-box label,
.terms-link {
  min-height: 44px;
}

.terms-agreement-box label {
  display: flex;
  align-items: center;
}

.terms-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-2);
  color: var(--c-text-secondary) !important;
  font-size: var(--text-sm) !important;
  font-weight: var(--weight-semibold);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.is-submitting {
  opacity: 0.78;
}

.is-submitting::after {
  content: '';
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: submit-spin 700ms linear infinite;
}

@keyframes submit-spin {
  to { transform: rotate(360deg); }
}

/* Public pages use the available viewport while forms keep a readable measure. */
.app-shell--public {
  max-width: 100%;
  box-shadow: none;
}

.app-shell--public .app-header,
.app-shell--public .app-main,
.app-shell--public .app-footer {
  width: 100%;
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.app-shell--public .app-main {
  padding-bottom: var(--sp-8);
}

.legal-page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.pricing-page {
  width: 100%;
  max-width: 960px !important;
}

.pricing-grid {
  display: grid !important;
  grid-template-columns: 1fr;
}

.home-page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

.home-feature-grid,
.home-faq-grid {
  display: grid !important;
  grid-template-columns: 1fr;
}

.app-footer a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--c-text-secondary) !important;
}

.records-stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: var(--sp-2) !important;
}

.records-stat-grid .card {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) var(--sp-2) !important;
}

@media (min-width: 640px) {
  .app-shell--public .app-header {
    padding: var(--sp-4) var(--sp-8);
  }

  .app-shell--public .app-main {
    padding: var(--sp-8);
  }

  .app-shell--public .app-footer {
    padding-left: var(--sp-8) !important;
    padding-right: var(--sp-8) !important;
  }

  .home-hero {
    padding: var(--sp-12) var(--sp-8) !important;
  }

  .home-hero h1 {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
    font-size: clamp(2.25rem, 5vw, 3.75rem) !important;
    line-height: 1.15 !important;
  }

  .home-hero > p {
    max-width: 640px !important;
    font-size: var(--text-lg) !important;
  }

  .home-hero-actions {
    max-width: 520px !important;
  }

  .home-feature-grid,
  .home-faq-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4) !important;
  }

  .home-steps {
    padding: var(--sp-8) !important;
  }

  .pricing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4) !important;
  }

  .records-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: var(--sp-3) !important;
  }
}

@media (min-width: 1024px) {
  .pricing-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Authenticated workspace: mobile bottom navigation becomes a desktop rail. */
@media (min-width: 640px) {
  .app-shell--authenticated {
    max-width: 800px;
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.05);
  }

  .app-shell--authenticated .app-header,
  .app-shell--authenticated .app-footer,
  .app-shell--authenticated .bottom-nav {
    max-width: 800px;
  }

  .app-shell--authenticated .app-main {
    padding: var(--sp-6);
    padding-bottom: calc(var(--sp-6) + 72px);
  }

  .app-shell--authenticated .studio-bottom-bar {
    max-width: 800px !important;
  }

  .modal-backdrop {
    align-items: center !important;
    padding: var(--sp-6);
  }

  .modal-drawer {
    width: min(680px, 100%) !important;
    max-width: 680px !important;
    border-radius: var(--radius-xl) !important;
  }
}

@media (min-width: 1024px) {
  .app-shell--authenticated {
    max-width: 1180px;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 208px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'header header'
      'nav main'
      'nav footer';
    align-items: stretch;
  }

  .app-shell--role-admin {
    max-width: 1280px;
  }

  .app-shell--authenticated .app-header {
    grid-area: header;
    width: 100%;
    max-width: none;
    padding: var(--sp-4) var(--sp-6);
  }

  .app-shell--authenticated .app-main {
    grid-area: main;
    min-width: 0;
    padding: var(--sp-8);
    padding-bottom: var(--sp-8);
  }

  .app-shell--authenticated .app-main > .page {
    width: 100%;
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
  }

  .app-shell--role-admin .app-main > .page {
    max-width: 1040px;
  }

  .app-shell--authenticated .app-footer {
    grid-area: footer;
    width: 100%;
    max-width: none;
    padding-bottom: var(--sp-6) !important;
  }

  .app-shell--authenticated .bottom-nav {
    grid-area: nav;
    position: sticky;
    top: var(--sp-4);
    bottom: auto;
    left: auto;
    align-self: start;
    transform: none;
    width: auto;
    max-width: none;
    display: flex !important;
    flex-direction: column;
    gap: var(--sp-1);
    margin: var(--sp-6) 0 var(--sp-6) var(--sp-4);
    padding: var(--sp-3);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
  }

  .app-shell--authenticated .bottom-nav-item {
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: var(--sp-3) !important;
    width: 100%;
    height: 48px;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
  }

  .app-shell--authenticated .bottom-nav-item.is-center-home {
    order: -1;
  }

  .app-shell--authenticated .bottom-nav-label {
    font-size: var(--text-sm) !important;
  }

  .app-shell--authenticated .bottom-nav-item.is-active {
    background: var(--c-primary-subtle);
  }

  .app-shell--authenticated .bottom-nav-item.is-active::after {
    top: 50%;
    left: 0;
    width: 3px;
    height: 24px;
    transform: translateY(-50%);
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
  }

  .app-shell--authenticated .studio-bottom-bar {
    position: sticky !important;
    bottom: 0 !important;
    left: auto !important;
    right: auto !important;
    max-width: none !important;
    margin: var(--sp-4) 0 0 !important;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
  }

  .dashboard-page {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: var(--sp-5);
  }

  .dashboard-page > * {
    min-width: 0;
  }

  .dashboard-span-full {
    grid-column: 1 / -1;
  }

  .dashboard-card {
    height: 100%;
    margin-bottom: 0 !important;
  }

  .admin-dashboard-page {
    gap: var(--sp-6);
  }

  .admin-stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    margin: 0 !important;
  }

  .admin-action-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3) !important;
    margin-top: 0 !important;
  }

  .admin-list-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3) !important;
  }

  .admin-list-grid > .empty {
    grid-column: 1 / -1;
  }

  .schedule-page {
    display: grid !important;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    align-items: start;
    gap: var(--sp-5) !important;
  }

  .schedule-page-header,
  .schedule-page-message,
  .schedule-month-list {
    grid-column: 1 / -1;
  }

  .schedule-calendar,
  .schedule-daily {
    margin-bottom: 0 !important;
  }

  .schedule-daily {
    position: sticky;
    top: 80px;
  }

  .schedule-page .cal-cell {
    min-height: 68px;
    padding-top: var(--sp-1);
  }
}

/* Role picker */
.role-picker {
  display: flex;
  gap: var(--sp-3);
}

.role-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.role-option:has(input:checked) {
  border-color: var(--c-primary);
  background: var(--c-primary-subtle);
  color: var(--c-primary-hover);
  font-weight: var(--weight-bold);
}

/* Social Logins — Official Brand Guidelines */
.social-auth-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 1rem;
  width: 100%;
}

.social-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--c-text-tertiary, #94a3b8);
  font-size: 0.75rem;
  margin: 1.125rem 0 0.75rem;
}

.social-divider::before,
.social-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--c-border, #e2e8f0);
}

.social-divider span {
  padding: 0 0.75rem;
}

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: opacity 0.15s ease, transform 0.1s ease;
  user-select: none;
}

.btn-social:active {
  transform: scale(0.985);
  opacity: 0.92;
}

.btn-social .social-icon,
.btn-social svg {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  max-width: 18px;
  max-height: 18px;
  flex-shrink: 0;
  display: block;
}

/* Kakao */
.btn-kakao {
  background-color: #FEE500;
  color: #191919;
  border: 1px solid #FEE500;
}

.btn-kakao:hover {
  background-color: #FADA0A;
}

/* Google */
.btn-google {
  background-color: #FFFFFF;
  color: #1F1F1F;
  border: 1px solid #DADCE0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-google:hover {
  background-color: #F8FAFC;
  border-color: #CBD5E1;
}

/* Apple */
.btn-apple {
  background-color: #000000;
  color: #FFFFFF;
  border: 1px solid #000000;
}

.btn-apple:hover {
  background-color: #1F1F1F;
}

/* =============================================
   Error Pages
   ============================================= */
.error-card {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
}

.error-code {
  font-size: var(--text-3xl);
  font-weight: var(--weight-extrabold);
  color: var(--c-primary);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.03em;
}

.error-message {
  color: var(--c-text-tertiary);
  margin-bottom: var(--sp-6);
}

/* =============================================
   Workout Form (Phase 4)
   ============================================= */
.exercise-block {
  padding: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.exercise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}

.exercise-name {
  flex: 1;
  height: 40px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

.exercise-body-part {
  width: 100%;
  height: 36px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-2);
}

.sets-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-2);
}

.set-row {
  display: grid;
  grid-template-columns: 1.75rem 1fr 1fr 2fr 1.75rem;
  align-items: center;
  gap: var(--sp-1);
}

.set-number {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--c-text-tertiary);
  text-align: center;
}

.set-weight,
.set-reps,
.set-memo {
  height: 36px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.set-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.set-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.set-item .set-number {
  min-width: 3rem;
  text-align: left;
}

.set-item .set-value {
  flex: 1;
  font-weight: var(--weight-semibold);
}

/* =============================================
   Invite / Code
   ============================================= */
.code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--c-bg);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  color: var(--c-text-secondary);
}

.invite-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-3);
}

/* =============================================
   Utilities
   ============================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard nav */
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
}

/* Scrollbar minimal */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--c-text-muted);
  border-radius: var(--radius-full);
}

/* =============================================
   Missing classes (Phase B audit)
   ============================================= */
.btn-add-set,
.btn-remove-exercise,
.btn-remove-set {
  font-size: var(--text-sm);
  color: var(--c-text-tertiary);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.btn-add-set:hover,
.btn-remove-exercise:hover,
.btn-remove-set:hover {
  color: var(--c-danger);
  background: var(--c-danger-subtle);
}

.member-item--link,
.session-item--link {
  padding: 0;
  border: none;
  background: none;
}

.member-item--link > a,
.session-item--link > a,
a.member-item,
a.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-surface);
  width: 100%;
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.member-item--link > a:hover,
.session-item--link > a:hover,
a.member-item:hover,
a.session-item:hover {
  border-color: var(--c-primary);
}

.session-highlight {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3);
  background: var(--c-primary-subtle);
  border-radius: var(--radius-md);
  border: 1px solid rgba(249, 115, 22, 0.15);
}

.session-date {
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--c-text);
}

.session-trainer {
  font-size: var(--text-sm);
  color: var(--c-text-secondary);
  font-weight: var(--weight-medium);
}

/* Alert styles */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.alert-success {
  background: var(--c-success-subtle);
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-danger, .alert-error {
  background: var(--c-danger-subtle);
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* InBody Chart Tabs */
.chart-tab {
  transition: all var(--transition-fast);
  color: var(--c-text-secondary);
}

.chart-tab.active {
  color: var(--c-text);
  box-shadow: var(--shadow-sm);
}

/* =============================================
   Calendar Grid & Monthly Schedule
   ============================================= */
.cal-container {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 0.75rem 0.5rem;
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
}

.cal-month-title {
  font-size: 1.0625rem;
  font-weight: var(--weight-bold);
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.cal-nav-btn:hover {
  background: var(--c-bg);
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.cal-grid-header {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  text-align: center;
  font-size: 0.75rem;
  font-weight: var(--weight-bold);
  color: var(--c-text-secondary);
  padding-bottom: 0.35rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--c-border-subtle);
  width: 100%;
}

.cal-grid-header > span:first-child {
  color: #ef4444; /* Sun */
}
.cal-grid-header > span:last-child {
  color: #3b82f6; /* Sat */
}

.cal-grid-body {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
}

.cal-cell {
  width: 100%;
  min-height: 52px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 3px 1px;
  border-radius: 6px;
  border: 1.5px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  user-select: none;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
  overflow: hidden;
  font-family: inherit;
  text-align: center;
}

.cal-cell:hover {
  background: var(--c-bg);
}

.cal-cell.is-other-month {
  opacity: 0.25;
}

.cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 0.8125rem;
  font-weight: var(--weight-medium);
  color: var(--c-text);
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}

.cal-cell.is-today .cal-day-num {
  background: var(--c-primary);
  color: #ffffff;
  border-radius: 9999px;
  font-weight: 800;
}

.cal-cell.is-selected {
  border-color: var(--c-primary);
  background: rgba(255, 158, 32, 0.08);
}

.cal-cell.is-sun .cal-day-num {
  color: #dc2626;
}

.cal-cell.is-sat .cal-day-num {
  color: #2563eb;
}

.cal-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 1px 3px;
  border-radius: 4px;
  background: rgba(255, 158, 32, 0.18);
  color: #d97706;
  white-space: nowrap;
  line-height: 1.2;
  max-width: 96%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.cal-badge.is-completed {
  background: rgba(33, 94, 97, 0.12);
  color: var(--c-teal);
}

.cal-badge.is-multi {
  background: var(--c-primary);
  color: #ffffff;
}

/* =============================================
   Naver Booking-Style Time Slot Scheduler
   ============================================= */
.booking-container {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
}

.booking-dates-ribbon {
  display: flex;
  gap: 0.375rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.booking-date-card {
  flex: 0 0 54px;
  height: 68px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  position: relative;
}

.booking-date-card:hover {
  border-color: var(--c-primary);
  background: var(--c-bg);
}

.booking-date-card.is-active {
  border-color: var(--c-primary);
  background: var(--c-primary);
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(255, 158, 32, 0.35);
}

.booking-date-card.is-active .booking-card-dow,
.booking-date-card.is-active .booking-card-day,
.booking-date-card.is-active .booking-card-today {
  color: #ffffff !important;
}

.booking-card-dow {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--c-text-secondary);
}

.booking-card-dow.is-sun {
  color: #ef4444;
}
.booking-card-dow.is-sat {
  color: #3b82f6;
}

.booking-card-day {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--c-text);
  line-height: 1.2;
}

.booking-card-today {
  font-size: 0.625rem;
  font-weight: 800;
  color: var(--c-primary);
}

.booking-time-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.375rem;
}

@media (max-width: 380px) {
  .booking-time-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.booking-time-btn {
  padding: 0.6rem 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.booking-time-btn:hover:not(:disabled) {
  border-color: var(--c-primary);
  background: var(--c-primary-subtle);
  color: var(--c-primary);
}

.booking-time-btn.is-selected {
  background: var(--c-primary) !important;
  border-color: var(--c-primary) !important;
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(255, 158, 32, 0.35);
}

.booking-time-btn:disabled,
.booking-time-btn.is-booked {
  background: var(--c-bg);
  border-color: var(--c-border-subtle);
  color: var(--c-text-muted);
  cursor: not-allowed;
  opacity: 0.65;
}

.booking-time-btn.is-booked span.booked-tag {
  font-size: 0.625rem;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
