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

    :root {
      --bg: #0a0a0f;
      --card: #14141f;
      --accent: #6c5ce7;
      --accent-glow: #a29bfe;
      --green: #00b894;
      --red: #e17055;
      --text: #f0f0f0;
      --muted: #636e82;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      min-height: 100dvh;
      display: flex;
      align-items: safe center;
      justify-content: center;
      overflow-y: auto;
      -webkit-user-select: none;
      user-select: none;
      -webkit-overflow-scrolling: touch;
    }

    .app { width: 100%; max-width: 1200px; padding: 2rem 1rem 4rem; text-align: center; }

    /* Lock scroll during workout */
    body.workout-active { overflow: hidden; }

    /* Start Screen */
    .start-screen { display: none; flex-direction: column; align-items: center; gap: 1.5rem; }
    .start-screen h1 {
      font-size: 4rem; font-weight: 800;
      background: linear-gradient(135deg, var(--accent-glow), var(--accent));
      -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    }
    .start-screen .subtitle { font-size: 1.2rem; color: var(--muted); }

    .today-exercises {
      display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
      gap: 0.6rem; width: 100%; max-width: 800px; margin: 0.5rem 0;
    }
    .ex-chip {
      background: var(--card); border-radius: 12px; padding: 0.5rem 0.7rem;
      font-size: 0.8rem; display: flex; align-items: center; gap: 0.5rem;
    }
    .ex-chip .num {
      background: var(--accent); color: #fff; border-radius: 50%;
      width: 20px; height: 20px; display: flex; align-items: center;
      justify-content: center; font-size: 0.65rem; font-weight: 700; flex-shrink: 0;
    }

    .btn {
      background: var(--accent); color: #fff; border: none;
      padding: 1.1rem 3rem; font-size: 1.4rem; font-weight: 700;
      border-radius: 20px; cursor: pointer; transition: all 0.2s;
    }
    .btn:hover { transform: scale(1.05); background: var(--accent-glow); }
    .btn:active { transform: scale(0.97); }
    .btn-small { padding: 0.7rem 1.8rem; font-size: 1rem; border-radius: 14px; }
    .btn-ghost { background: var(--card); }

    /* Workout Screen */
    .workout-screen { display: none; flex-direction: column; align-items: center; gap: 0.8rem; }
    .workout-header {
      display: flex; align-items: center; justify-content: space-between;
      width: 100%; max-width: 800px;
    }
    .workout-header .phase-label { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
    .workout-header .total-time { font-size: 1.2rem; font-weight: 600; color: var(--muted); }
    .progress-bar-container { width: 100%; max-width: 800px; height: 6px; background: var(--card); border-radius: 3px; overflow: hidden; }
    .progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }

    /* Figure */
    .figure-container {
      width: 280px; height: 280px; margin: 0.25rem 0;
      filter: drop-shadow(0 0 25px rgba(162, 155, 254, 0.25));
      position: relative;
      overflow: hidden;
      border-radius: 20px;
    }
    .figure-container svg { width: 100%; height: 100%; }

    /* Photo animation: crossfade between start/end positions */
    .photo-anim {
      position: relative;
      width: 100%; height: 100%;
      background: var(--card);
      border-radius: 20px;
      overflow: hidden;
    }
    .photo-anim img {
      position: absolute;
      top: 0; left: 0;
      width: 100%; height: 100%;
      object-fit: contain;
      background: var(--card);
      border-radius: 20px;
    }
    .photo-anim .pose-a {
      animation: fadeToggle 1.6s ease-in-out infinite;
    }
    .photo-anim .pose-b {
      animation: fadeToggle 1.6s ease-in-out infinite;
      animation-delay: 0.8s;
      opacity: 0;
    }
    @keyframes fadeToggle {
      0%, 45% { opacity: 1; }
      55%, 100% { opacity: 0; }
    }
    .photo-anim .loading-spinner {
      position: absolute;
      top: 50%; left: 50%;
      transform: translate(-50%, -50%);
      width: 36px; height: 36px;
      border: 3px solid var(--card);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }
    @keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

    .exercise-name { font-size: 3rem; font-weight: 800; line-height: 1.1; }
    .exercise-description { font-size: 1.05rem; color: var(--muted); max-width: 500px; }

    .timer-ring-container { position: relative; width: 160px; height: 160px; }
    .timer-ring-container > svg { transform: rotate(-90deg); width: 160px; height: 160px; }
    .timer-ring-bg { fill: none; stroke: var(--card); stroke-width: 8; }
    .timer-ring-progress { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.1s linear, stroke 0.3s; }
    .timer-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 3.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }

    .rest-phase .exercise-name { color: var(--green); }
    .rest-phase .timer-ring-progress { stroke: var(--green); }
    .ending-soon .timer-ring-progress { stroke: var(--red); }
    .ending-soon .timer-text { color: var(--red); }

    .next-up { font-size: 1rem; color: var(--muted); }
    .next-up strong { color: var(--text); }

    /* Next exercise preview during rest */
    .next-preview {
      display: flex;
      align-items: center;
      gap: 1rem;
      background: var(--card);
      border-radius: 16px;
      padding: 0.8rem 1.2rem;
      margin-top: 0.25rem;
      max-width: 400px;
      width: 100%;
    }
    .next-preview-fig {
      width: 80px; height: 80px; flex-shrink: 0;
      border-radius: 12px; overflow: hidden; background: var(--bg);
    }
    .next-preview-fig img { width: 100%; height: 100%; object-fit: contain; }
    .next-preview-fig svg { width: 100%; height: 100%; }
    .next-preview-info { text-align: left; }
    .next-preview-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
    .next-preview-name { font-size: 1.1rem; font-weight: 700; margin-top: 0.15rem; }
    .next-preview-desc { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

    /* Countdown overlay */
    .countdown-overlay {
      position: fixed;
      top: 0; left: 0; width: 100%; height: 100%;
      background: var(--bg);
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      z-index: 100;
      gap: 1.5rem;
    }
    .countdown-number {
      font-size: 10rem;
      font-weight: 900;
      color: var(--accent);
      line-height: 1;
      animation: countPulse 0.6s ease-out;
    }
    .countdown-go {
      font-size: 6rem;
      font-weight: 900;
      color: var(--green);
      animation: countPulse 0.4s ease-out;
    }
    .countdown-label {
      font-size: 1.3rem;
      color: var(--muted);
      font-weight: 600;
    }
    .countdown-exercise {
      font-size: 1.8rem;
      font-weight: 800;
      color: var(--text);
    }
    @keyframes countPulse {
      0% { transform: scale(1.4); opacity: 0.5; }
      100% { transform: scale(1); opacity: 1; }
    }

    /* Side indicator badge (LEFT / RIGHT) */
    .side-badge {
      display: inline-block;
      padding: 0.3rem 1rem;
      border-radius: 12px;
      font-size: 0.9rem;
      font-weight: 800;
      letter-spacing: 0.15em;
      text-transform: uppercase;
      color: #fff;
      background: var(--accent);
      margin-bottom: 0.15rem;
    }
    .side-badge.side-left { background: #0984e3; }
    .side-badge.side-right { background: #e17055; }

    /* Switch flash overlay */
    .switch-flash {
      position: fixed;
      top: 0; left: 0; width: 100%; height: 100%;
      display: flex; align-items: center; justify-content: center;
      background: rgba(10, 10, 15, 0.85);
      z-index: 90;
      animation: flashIn 0.8s ease-out forwards;
      pointer-events: none;
    }
    .switch-flash-text {
      font-size: 3rem;
      font-weight: 900;
      color: #e17055;
      animation: switchPop 0.5s ease-out;
    }
    @keyframes flashIn {
      0% { opacity: 1; }
      85% { opacity: 1; }
      100% { opacity: 0; }
    }
    @keyframes switchPop {
      0% { transform: scale(0.5); opacity: 0; }
      50% { transform: scale(1.2); }
      100% { transform: scale(1); opacity: 1; }
    }

    .controls { display: flex; gap: 1rem; margin-top: 0.15rem; }
    .btn-icon {
      background: var(--card); color: var(--text); border: none;
      width: 52px; height: 52px; border-radius: 50%; font-size: 1.3rem;
      cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s;
    }
    .btn-icon:hover { background: var(--accent); }
    .btn-icon svg { width: 24px; height: 24px; fill: var(--text); }

    /* Done Screen */
    .done-screen { display: none; flex-direction: column; align-items: center; gap: 2rem; }
    .done-check { width: 120px; height: 120px; }
    .done-check .circle { fill: none; stroke: var(--green); stroke-width: 4; }
    .done-check .check { fill: none; stroke: var(--green); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
      stroke-dasharray: 60; stroke-dashoffset: 60; animation: drawCheck 0.6s 0.3s ease forwards; }
    @keyframes drawCheck { to { stroke-dashoffset: 0; } }

    .done-screen h1 { font-size: 2.8rem; font-weight: 800; color: var(--green); }
    .done-stats { display: flex; gap: 2rem; }
    .done-stat { background: var(--card); padding: 1.5rem 2rem; border-radius: 16px; text-align: center; }
    .done-stat .val { font-size: 2.5rem; font-weight: 800; }
    .done-stat .label { font-size: 0.9rem; color: var(--muted); margin-top: 0.25rem; }

    @media (max-width: 768px) {
      .app { padding: 1rem; }
      .start-screen h1 { font-size: 2.5rem; }
      .exercise-name { font-size: 2rem; }
      .figure-container { width: 220px; height: 220px; }
      .timer-ring-container { width: 120px; height: 120px; }
      .timer-ring-container > svg { width: 120px; height: 120px; }
      .timer-text { font-size: 2.4rem; }
      .today-exercises { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    }
    @media (min-width: 1400px) {
      .exercise-name { font-size: 4rem; }
      .figure-container { width: 400px; height: 400px; }
      .timer-ring-container { width: 200px; height: 200px; }
      .timer-ring-container > svg { width: 200px; height: 200px; }
      .timer-text { font-size: 4rem; }
    }

    /* Category Badge */
    .category-badge {
      display: inline-block; padding: 0.4rem 1.2rem; border-radius: 20px;
      font-size: 0.85rem; font-weight: 700; letter-spacing: 0.12em;
      text-transform: uppercase; color: #fff; margin-bottom: 0.25rem;
    }
    .category-badge.cat-cardio { background: #e17055; }
    .category-badge.cat-strength { background: #0984e3; }
    .category-badge.cat-core { background: #6c5ce7; }
    .category-badge.cat-flexibility { background: #00b894; }
    .category-badge.cat-full { background: linear-gradient(135deg, #e17055, #0984e3, #6c5ce7, #00b894); }
    .category-badge.cat-rest { background: #636e82; }

    .category-label {
      font-size: 1.6rem; font-weight: 800; letter-spacing: 0.08em;
      text-transform: uppercase; margin-bottom: 0.25rem;
    }
    .category-label.cat-cardio { color: #e17055; }
    .category-label.cat-strength { color: #0984e3; }
    .category-label.cat-core { color: #6c5ce7; }
    .category-label.cat-flexibility { color: #00b894; }
    .category-label.cat-full {
      background: linear-gradient(135deg, #e17055, #0984e3, #6c5ce7, #00b894);
      -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    }
    .category-label.cat-rest { color: #636e82; }

    /* Weekly Schedule Row */
    .weekly-schedule {
      display: flex; gap: 0.5rem; justify-content: center; align-items: center;
      margin: 0.25rem 0;
    }
    .day-circle {
      width: 36px; height: 36px; border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-size: 0.7rem; font-weight: 700; color: var(--muted);
      background: var(--card); border: 2px solid transparent;
      transition: all 0.2s; position: relative;
    }
    .day-circle.today { border-color: var(--accent); color: var(--text); }
    .day-circle.completed { background: var(--green); color: #fff; border-color: var(--green); }
    .day-circle .day-cat-dot {
      position: absolute; bottom: -6px; width: 6px; height: 6px;
      border-radius: 50%;
    }
    .day-cat-dot.cat-cardio { background: #e17055; }
    .day-cat-dot.cat-strength { background: #0984e3; }
    .day-cat-dot.cat-core { background: #6c5ce7; }
    .day-cat-dot.cat-flexibility { background: #00b894; }
    .day-cat-dot.cat-full { background: var(--accent); }
    .day-cat-dot.cat-rest { background: #636e82; }

    /* Rest Day Screen */
    .rest-day-content {
      display: flex; flex-direction: column; align-items: center;
      gap: 1.5rem; padding: 2rem 0;
    }
    .rest-icon { width: 120px; height: 120px; opacity: 0.9; }
    .rest-day-content h2 { font-size: 2.5rem; font-weight: 800; color: var(--green); }
    .rest-day-content p { font-size: 1.1rem; color: var(--muted); max-width: 400px; line-height: 1.6; }

    /* Progress Screen */
    .progress-screen {
      display: none; flex-direction: column; align-items: center;
      gap: 1.5rem; width: 100%; max-width: 600px; margin: 0 auto;
    }
    .progress-header {
      display: flex; align-items: center; justify-content: space-between;
      width: 100%;
    }
    .progress-header h2 {
      font-size: 1.8rem; font-weight: 800;
      background: linear-gradient(135deg, var(--accent-glow), var(--accent));
      -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    }

    .stats-row { display: flex; gap: 1.5rem; width: 100%; }
    .stat-card {
      flex: 1; background: var(--card); border-radius: 16px;
      padding: 1.2rem; text-align: center;
    }
    .stat-card .stat-icon { margin-bottom: 0.5rem; }
    .stat-card .stat-val { font-size: 2.2rem; font-weight: 800; }
    .stat-card .stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
    .streak-val { color: #fd9644; }

    /* Calendar */
    .calendar-container {
      width: 100%; background: var(--card); border-radius: 16px;
      padding: 1.2rem;
    }
    .calendar-nav {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 1rem;
    }
    .calendar-nav .month-label { font-size: 1.1rem; font-weight: 700; }
    .calendar-nav button {
      background: none; border: none; color: var(--text); font-size: 1.2rem;
      cursor: pointer; padding: 0.3rem 0.6rem; border-radius: 8px;
    }
    .calendar-nav button:hover { background: rgba(255,255,255,0.1); }
    .calendar-grid {
      display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
      text-align: center;
    }
    .calendar-grid .day-header {
      font-size: 0.65rem; font-weight: 700; color: var(--muted);
      padding: 0.3rem 0; text-transform: uppercase;
    }
    .calendar-cell {
      aspect-ratio: 1; display: flex; flex-direction: column;
      align-items: center; justify-content: center; border-radius: 50%;
      font-size: 0.8rem; font-weight: 600; color: var(--muted);
      position: relative; width: 36px; height: 36px; margin: 0 auto;
    }
    .calendar-cell.today-cell {
      box-shadow: inset 0 0 0 2px var(--accent); color: var(--text);
    }
    .calendar-cell.completed-cell { background: var(--green); color: #fff; }
    .calendar-cell.completed-cell.today-cell {
      background: var(--green); box-shadow: inset 0 0 0 2px var(--accent-glow);
    }
    .calendar-cell .cal-cat-dot {
      position: absolute; bottom: 1px; width: 5px; height: 5px;
      border-radius: 50%;
    }
    .calendar-cell.empty { visibility: hidden; }

    /* Done screen streak */
    .done-streak {
      display: flex; align-items: center; gap: 0.5rem;
      font-size: 1.3rem; font-weight: 700; color: #fd9644;
    }
    .done-streak svg { width: 28px; height: 28px; }
    .done-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

    @media (max-width: 768px) {
      .category-label { font-size: 1.2rem; }
      .day-circle { width: 32px; height: 32px; font-size: 0.65rem; }
      .stats-row { gap: 0.8rem; }
      .stat-card .stat-val { font-size: 1.6rem; }
      .calendar-cell { width: 32px; height: 32px; font-size: 0.7rem; }
      .rest-day-content h2 { font-size: 2rem; }
    }

    /* Settings Screen */
    .settings-screen {
      display: none; flex-direction: column; align-items: center;
      width: 100%; max-width: 700px; margin: 0 auto; gap: 1rem;
    }
    .settings-header {
      display: flex; align-items: center; justify-content: space-between;
      width: 100%; margin-bottom: 0.5rem;
    }
    .settings-header h2 { font-size: 1.5rem; font-weight: 800; }

    .settings-cat-title {
      width: 100%; text-align: left; font-size: 0.85rem; font-weight: 700;
      text-transform: uppercase; letter-spacing: 0.1em; padding: 0.5rem 0 0.25rem;
      border-bottom: 1px solid var(--card);
    }
    .settings-cat-title.cat-cardio { color: #e17055; }
    .settings-cat-title.cat-strength { color: #0984e3; }
    .settings-cat-title.cat-core { color: #6c5ce7; }
    .settings-cat-title.cat-flexibility { color: #00b894; }

    .exercise-toggle {
      display: flex; align-items: center; justify-content: space-between;
      width: 100%; padding: 0.6rem 0.8rem; background: var(--card);
      border-radius: 10px; margin-bottom: 0.3rem;
    }
    .exercise-toggle-info {
      display: flex; flex-direction: column; text-align: left; flex: 1; min-width: 0;
    }
    .exercise-toggle-name { font-weight: 700; font-size: 0.9rem; }
    .exercise-toggle-desc { font-size: 0.75rem; color: var(--muted); margin-top: 0.1rem; }
    .exercise-toggle-disabled .exercise-toggle-name { color: var(--muted); text-decoration: line-through; }

    /* Toggle switch */
    .toggle {
      position: relative; width: 44px; height: 24px; flex-shrink: 0; margin-left: 0.8rem;
    }
    .toggle input { opacity: 0; width: 0; height: 0; }
    .toggle-slider {
      position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
      background: #2d3436; border-radius: 24px; transition: 0.2s;
    }
    .toggle-slider:before {
      content: ""; position: absolute; height: 18px; width: 18px;
      left: 3px; bottom: 3px; background: #636e82;
      border-radius: 50%; transition: 0.2s;
    }
    .toggle input:checked + .toggle-slider { background: var(--accent); }
    .toggle input:checked + .toggle-slider:before { transform: translateX(20px); background: #fff; }

    .settings-count {
      font-size: 0.85rem; color: var(--muted); width: 100%; text-align: center;
      padding: 0.5rem 0;
    }
    .settings-count strong { color: var(--text); }

    /* Login Screen */
    .login-screen {
      display: none; flex-direction: column; align-items: center;
      gap: 1.5rem; width: 100%; max-width: 400px; margin: 0 auto;
    }
    .login-screen h1 {
      font-size: 2.5rem; font-weight: 800;
      background: linear-gradient(135deg, var(--accent-glow), var(--accent));
      -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    }
    .login-screen h2 { font-size: 1.3rem; font-weight: 700; color: var(--muted); }
    .login-error {
      color: var(--red); font-size: 0.85rem; font-weight: 600;
      min-height: 1.2em;
    }

    .login-avatar {
      width: 56px; height: 56px; border-radius: 50%;
      background: var(--accent); color: #fff;
      display: flex; align-items: center; justify-content: center;
      font-size: 1.6rem; font-weight: 800;
    }

    .pin-display {
      display: flex; gap: 12px; justify-content: center;
      margin: 0.5rem 0;
    }
    .pin-dot {
      width: 16px; height: 16px; border-radius: 50%;
      border: 2px solid var(--muted); transition: all 0.15s;
    }
    .pin-dot.filled {
      background: var(--accent); border-color: var(--accent);
    }

    .numpad {
      display: grid; grid-template-columns: repeat(3, 1fr);
      gap: 10px; width: 220px; margin: 0 auto;
    }
    .numpad-btn {
      width: 60px; height: 60px; border-radius: 50%;
      background: var(--card); color: var(--text); border: none;
      font-size: 1.4rem; font-weight: 700; cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: all 0.15s; margin: 0 auto;
    }
    .numpad-btn:hover { background: var(--accent); }
    .numpad-btn:active { transform: scale(0.92); }
    .numpad-btn.empty { visibility: hidden; pointer-events: none; }
    .numpad-btn svg { width: 24px; height: 24px; fill: var(--text); }

    .login-link {
      color: var(--accent-glow); font-size: 0.95rem; font-weight: 600;
      cursor: pointer; text-decoration: underline; background: none; border: none;
    }
    .login-link:hover { color: var(--accent); }

    .register-form {
      display: flex; flex-direction: column; align-items: center;
      gap: 1rem; width: 100%;
    }
    .register-form label {
      font-size: 0.85rem; color: var(--muted); font-weight: 600;
      width: 100%; text-align: left;
    }
    .register-input {
      width: 100%; padding: 0.8rem 1rem; border-radius: 12px;
      background: var(--card); border: 2px solid transparent;
      color: var(--text); font-size: 1rem; font-weight: 600;
      outline: none; transition: border-color 0.2s;
    }
    .register-input:focus { border-color: var(--accent); }
    .register-input::placeholder { color: var(--muted); }

    .register-actions {
      display: flex; gap: 0.8rem; width: 100%; justify-content: center;
    }

    .btn-logout {
      background: none; border: 1px solid var(--muted); color: var(--muted);
      padding: 0.5rem 1.2rem; font-size: 0.75rem; font-weight: 700;
      border-radius: 10px; cursor: pointer; letter-spacing: 0.08em;
      transition: all 0.2s;
    }
    .btn-logout:hover { border-color: var(--red); color: var(--red); }

    /* Category picker */
    .cat-picker {
      display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center;
      margin: 0.25rem 0;
    }
    .cat-picker-btn {
      padding: 0.35rem 0.8rem; border-radius: 20px; border: 2px solid var(--card);
      background: var(--card); color: var(--muted); font-size: 0.75rem;
      font-weight: 700; cursor: pointer; transition: all 0.2s;
      letter-spacing: 0.05em;
    }
    .cat-picker-btn:hover { border-color: var(--muted); }
    .cat-picker-btn.active { color: #fff; }
    .cat-picker-btn.active.cat-cardio { background: #e17055; border-color: #e17055; }
    .cat-picker-btn.active.cat-strength { background: #0984e3; border-color: #0984e3; }
    .cat-picker-btn.active.cat-core { background: #6c5ce7; border-color: #6c5ce7; }
    .cat-picker-btn.active.cat-flexibility { background: #00b894; border-color: #00b894; }
    .cat-picker-btn.active.cat-full { background: linear-gradient(135deg, #e17055, #0984e3, #6c5ce7, #00b894); border-color: #6c5ce7; }
    .cat-picker-suggested {
      font-size: 0.7rem; color: var(--muted); margin-top: 0.15rem;
    }
