/**
 * MyTracker - Complete Mobile-First CSS3 Stylesheet
 * Zero External Dependencies | 100dvh Dynamic Viewport | OLED Dark & Light Themes | Safe-Areas | Print Ready
 */

:root,
[data-theme="black"] {
    --bg-app: #000000;
    --bg-surface: #0a0a0a;
    --bg-elevated: #121212;
    --bg-input: #070707;
    --bg-glass: rgba(10, 10, 10, 0.92);
    --border-color: #1f1f1f;
    --border-strong: #2e2e2e;

    --text-main: #f8fafc;
    --text-secondary: #d4d4d8;
    --text-muted: #8e8e93;

    --accent-primary: #10b981;
    --accent-primary-hover: #059669;
    --accent-primary-soft: rgba(16, 185, 129, 0.16);

    --accent-secondary: #0ea5e9;
    --accent-blue: var(--accent-secondary);
    --accent-blue-soft: rgba(14, 165, 233, 0.16);

    --accent-purple: #a855f7;
    --accent-purple-soft: rgba(168, 85, 247, 0.16);

    --accent-amber: #f59e0b;
    --accent-amber-soft: rgba(245, 158, 11, 0.16);

    --accent-danger: #f43f5e;
    --accent-danger-soft: rgba(244, 63, 94, 0.16);

    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.65);
    --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.85);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 9999px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-height: 64px;
}

[data-theme="dark"] {
    --bg-app: #0a0e17;
    --bg-surface: #121926;
    --bg-elevated: #1a2333;
    --bg-input: #0e1420;
    --bg-glass: rgba(18, 25, 38, 0.88);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --accent-primary-soft: rgba(16, 185, 129, 0.15);
    --accent-blue: var(--accent-secondary);
    --accent-blue-soft: rgba(14, 165, 233, 0.15);

    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-sheet: 0 -10px 40px rgba(0, 0, 0, 0.65);
}

[data-theme="light"] {
    --bg-app: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-elevated: #f8fafc;
    --bg-input: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.92);
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;

    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --accent-primary: #059669;
    --accent-primary-hover: #047857;
    --accent-primary-soft: rgba(5, 150, 105, 0.12);

    --accent-blue: #0284c7;
    --accent-blue-soft: rgba(2, 132, 199, 0.12);

    --accent-purple: #9333ea;
    --accent-purple-soft: rgba(147, 51, 234, 0.12);

    --accent-amber: #d97706;
    --accent-amber-soft: rgba(217, 119, 6, 0.14);

    --accent-danger: #e11d48;
    --accent-danger-soft: rgba(225, 29, 72, 0.12);

    --shadow-card: 0 2px 12px rgba(15, 23, 42, 0.06);
    --shadow-sheet: 0 -8px 30px rgba(15, 23, 42, 0.18);
}

/* ==========================================================
   RESET & TYPOGRAPHY
   ========================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

.tabular-nums,
input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"],
.kpi-value,
.rest-timer-clock {
    font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4 {
    margin: 0 0 0.35rem 0;
    font-weight: 700;
    letter-spacing: -0.015em;
}

p {
    margin: 0 0 0.5rem 0;
}

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

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-emerald { color: var(--accent-primary); }
.text-blue { color: var(--accent-blue); }
.text-purple { color: var(--accent-purple); }
.text-amber { color: var(--accent-amber); }
.text-danger { color: var(--accent-danger); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.74rem; }
.text-right { text-align: right; }
.is-hidden { display: none !important; }

/* ==========================================================
   SPA VIEWPORT SHELL (100dvh)
   ========================================================== */
.app-body {
    overflow: hidden;
    height: 100dvh;
    width: 100%;
}

.app-viewport {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 680px;
    margin: 0 auto;
    background: var(--bg-app);
    position: relative;
}

/* ==========================================================
   TOPBAR & TIME-MACHINE CALENDAR HEADER
   ========================================================== */
.app-topbar {
    flex-shrink: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding-top: var(--safe-top);
    z-index: 20;
}

.topbar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    min-height: 52px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

.brand-title {
    font-size: 1.12rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--accent-amber-soft);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.sync-pulse {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-amber);
    animation: pulseGlow 1.4s infinite ease-in-out;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.82); }
}

/* Time-Machine 7-Day Horizontal Strip */
.time-machine-bar {
    padding: 0.15rem 0.5rem 0.55rem;
}

.week-strip-controls {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.week-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem 0.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.week-nav-btn:active {
    background: var(--bg-elevated);
    color: var(--text-main);
}

.week-strip-days {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.25rem;
}

.day-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.15rem 0.32rem;
    border-radius: 11px;
    background: var(--bg-elevated);
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}

.day-pill:active {
    transform: scale(0.95);
}

.day-pill.is-today {
    border-color: rgba(16, 185, 129, 0.45);
}

.day-pill.is-selected {
    background: var(--accent-primary-soft);
    border-color: var(--accent-primary);
}

.day-pill-wd {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.day-pill.is-selected .day-pill-wd {
    color: var(--accent-primary);
}

.day-pill-num {
    font-size: 0.92rem;
    font-weight: 700;
    margin: 1px 0 3px;
    font-variant-numeric: tabular-nums;
}

.day-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 6px;
}

.dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.dot-gym { background-color: #10b981; }
.dot-food { background-color: #0ea5e9; }
.dot-supp { background-color: #a855f7; }
.dot-weight { background-color: #f59e0b; }

/* Expandable Monthly Calendar Heatmap */
.month-heatmap-drawer {
    margin-top: 0.55rem;
    padding: 0.7rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.month-heatmap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.45rem;
}

.month-weekdays-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.3rem;
}

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

.heatmap-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.1rem;
    border-radius: 8px;
    background: var(--bg-surface);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    min-height: 38px;
}

.heatmap-cell.is-outside {
    opacity: 0.3;
    pointer-events: none;
}

.heatmap-cell.is-selected {
    border-color: var(--accent-primary);
    background: var(--accent-primary-soft);
}

.heatmap-cell.is-today {
    color: var(--accent-primary);
    font-weight: 800;
}

.heatmap-legend {
    display: flex;
    justify-content: center;
    gap: 0.9rem;
    margin-top: 0.55rem;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.heatmap-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================
   MAIN SCROLL AREA & CARDS
   ========================================================== */
.app-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.85rem 0.9rem calc(var(--nav-height) + var(--safe-bottom) + 5.5rem);
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.95rem;
    margin-bottom: 0.85rem;
    box-shadow: var(--shadow-card);
}

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 0.98rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.card-subtitle {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* Week-over-Week Comparison Strip */
.week-compare-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
}

.week-compare-item {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.45rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.week-compare-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    display: block;
}

.week-compare-val {
    font-size: 0.92rem;
    font-weight: 800;
    display: block;
    margin: 2px 0;
}

.week-compare-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ==========================================================
   INTERACTIVE GHOST VALUES & STEPPERS
   ========================================================== */
.ghost-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}

.ghost-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
    user-select: none;
    transition: all 0.14s ease;
}

.ghost-chip:hover,
.ghost-chip:active {
    background: var(--accent-primary-soft);
    border-color: var(--accent-primary);
    border-style: solid;
    color: var(--accent-primary);
    transform: translateY(-1px);
}

.stepper-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}

.stepper-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    padding: 0.48rem 0.3rem;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.stepper-btn:active {
    background: var(--accent-primary-soft);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ==========================================================
   FORMS, INPUTS & BUTTONS
   ========================================================== */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
}

.input,
select.input,
textarea.input {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.62rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
    color: var(--text-muted);
    opacity: 0.65;
}

.input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-soft);
}

.input-row {
    display: flex;
    gap: 0.45rem;
    align-items: stretch;
}

.input-row .input {
    flex: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s ease, background 0.15s ease, opacity 0.15s ease;
}

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

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-primary);
    color: #04130d;
}

[data-theme="light"] .btn-primary {
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-primary-hover);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-main);
    border-color: var(--border-strong);
}

.btn-danger {
    background: var(--accent-danger-soft);
    color: var(--accent-danger);
    border-color: rgba(244, 63, 94, 0.35);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.38rem 0.68rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.78rem 1.2rem;
    font-size: 1rem;
}

.btn-icon {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.btn-icon:active {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
}

.btn-chip,
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.32rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.btn-chip.is-active,
.chip.is-active {
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-chip-danger {
    background: var(--accent-danger-soft);
    color: var(--accent-danger);
}

/* ==========================================================
   NUTRITION PROGRESS BARS & RINGS
   ========================================================== */
.macro-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.macro-summary-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.38rem;
    margin-bottom: 0.75rem;
}

.macro-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.45rem;
    text-align: center;
}

.macro-box-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.macro-box-val {
    font-size: 0.92rem;
    font-weight: 800;
    margin: 2px 0 4px;
    display: block;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: var(--accent-primary);
    transition: width 0.25s ease;
}

.progress-fill.is-blue { background: var(--accent-blue); }
.progress-fill.is-purple { background: var(--accent-purple); }
.progress-fill.is-amber { background: var(--accent-amber); }
.progress-fill.is-danger { background: var(--accent-danger); }

/* ==========================================================
   SUPPLEMENTS CHECKLIST & MICRONUTRIENTS
   ========================================================== */
.supp-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.supp-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.supp-item.is-taken {
    border-color: rgba(16, 185, 129, 0.5);
    background: var(--accent-primary-soft);
}

.supp-check-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--bg-input);
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.supp-item.is-taken .supp-check-btn {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #04130d;
}

.supp-thumb {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.supp-info {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.supp-name {
    font-weight: 700;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.supp-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stock-warning-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    background: var(--accent-amber-soft);
    color: var(--accent-amber);
}

.micro-pills-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border-color);
}

.micro-pill {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-pill);
    background: var(--accent-purple-soft);
    color: var(--accent-purple);
    font-weight: 600;
}

/* ==========================================================
   GYM & WORKOUTS, PINNED SETUP NOTES, PR BADGES & MUSCLE MAP
   ========================================================== */
.subnav-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
    background: var(--bg-surface);
    padding: 0.3rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 0.85rem;
}

.subnav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 0.35rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.subnav-btn.is-active {
    background: var(--bg-elevated);
    color: var(--accent-primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.badge-pill {
    font-size: 0.68rem;
    padding: 0.08rem 0.42rem;
    border-radius: var(--radius-pill);
    background: var(--accent-primary);
    color: #04130d;
    font-weight: 800;
}

/* Pinned Setup Notes for Machines & Cables */
.setup-note-banner {
    background: var(--accent-amber-soft);
    border-left: 3px solid var(--accent-amber);
    color: var(--text-main);
    padding: 0.45rem 0.65rem;
    border-radius: 6px;
    font-size: 0.8rem;
    margin: 0.4rem 0 0.65rem;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

/* Logged Sets Table inside Exercise Card */
.sets-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.7rem;
}

.set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.88rem;
}

.set-num {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
}

.set-type-badge {
    font-size: 0.66rem;
    font-weight: 800;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
    margin-left: 0.35rem;
}

.set-type-warmup { background: var(--accent-amber-soft); color: var(--accent-amber); }
.set-type-drop { background: var(--accent-purple-soft); color: var(--accent-purple); }
.set-type-failure { background: var(--accent-danger-soft); color: var(--accent-danger); }

.pr-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.12rem 0.45rem;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, #f59e0b, #eab308);
    color: #090d16;
    margin-left: 0.4rem;
}

/* Interactive Anatomical MuscleWiki-Style Map SVG */
.muscle-map-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    background: #0d0d0d;
    padding: 0.75rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.muscle-map-figure {
    text-align: center;
}

.muscle-map-caption {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.muscle-svg {
    width: 100%;
    max-width: 155px;
    height: auto;
    user-select: none;
}

.muscle-silhouette {
    fill: #080808;
    stroke: #e2e8f0;
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.muscle-contour {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 1.3;
    stroke-linecap: round;
    pointer-events: none;
}

.muscle-zone {
    fill: #6e6e6e;
    stroke: #ffffff;
    stroke-width: 1.35;
    stroke-linejoin: round;
    cursor: pointer;
    transition: fill 0.14s ease, filter 0.14s ease;
}

.muscle-zone:hover {
    fill: #8c8c8c;
}

.muscle-zone.is-active {
    fill: var(--accent-primary);
    stroke: #ffffff;
    filter: drop-shadow(0 0 6px var(--accent-primary));
}

.muscle-zone.is-secondary {
    fill: var(--accent-secondary);
    stroke: #ffffff;
    filter: drop-shadow(0 0 5px var(--accent-secondary));
}

/* ==========================================================
   FLOATING REST TIMER & 5-SECOND UNDO TOAST
   ========================================================== */
.floating-rest-timer {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 10px);
    width: calc(100% - 1.6rem);
    max-width: 640px;
    background: var(--bg-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-pill);
    padding: 0.45rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    z-index: 35;
}

.rest-timer-left {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.rest-timer-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.rest-timer-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.1;
}

.rest-timer-clock {
    font-size: 1.05rem;
    color: var(--accent-primary);
}

.rest-timer-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.undo-toast {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 68px);
    width: calc(100% - 1.8rem);
    max-width: 520px;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    z-index: 60;
}

.undo-toast-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.9rem;
    font-size: 0.88rem;
    font-weight: 600;
}

.btn-undo {
    background: var(--accent-primary);
    color: #04130d;
    border: none;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
}

.undo-progress-track {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.12);
}

.undo-progress-bar {
    height: 100%;
    background: var(--accent-primary);
    width: 100%;
    transition: width 5s linear;
}

/* ==========================================================
   BOTTOM-SHEET MODAL & UNIVERSAL HISTORY DRAWER
   ========================================================== */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    backdrop-filter: blur(3px);
    z-index: 70;
}

.bottom-sheet {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 680px;
    max-height: 90dvh;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-strong);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-sheet);
    display: flex;
    flex-direction: column;
    z-index: 80;
    padding-bottom: var(--safe-bottom);
    animation: sheetSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetSlideUp {
    from { transform: translate(-50%, 100%); }
    to { transform: translate(-50%, 0); }
}

.sheet-handle-bar {
    display: flex;
    justify-content: center;
    padding: 0.55rem 0 0.2rem;
    cursor: grab;
}

.sheet-pill {
    width: 42px;
    height: 5px;
    border-radius: var(--radius-pill);
    background: var(--border-strong);
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1.1rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.sheet-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 1.1rem 12rem; /* Extra bottom padding for mobile virtual keyboard (Guardrail D) */
}

/* ==========================================================
   BOTTOM NAVIGATION BAR
   ========================================================== */
.app-bottomnav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 100%;
    max-width: 680px;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    z-index: 40;
}

.nav-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.66rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    padding: 0 2px;
}

/* ==========================================================
   STREAKS (NN), HABITS, STUDY TIMER & COLOR SWATCHES
   ========================================================== */
.streak-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    margin-bottom: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.streak-days-big {
    font-size: 1.55rem;
    font-weight: 900;
    color: var(--accent-primary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stopwatch-display {
    font-size: 2.35rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    color: var(--accent-secondary);
    text-align: center;
    margin: 0.5rem 0;
    font-variant-numeric: tabular-nums;
}

.color-swatch-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.35rem;
}

.color-swatch-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.color-swatch-btn.is-active {
    border-color: #ffffff;
    transform: scale(1.15);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.barcode-video-wrap {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto 0.75rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 2px solid var(--accent-primary);
}

.barcode-video-wrap video {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.nav-tab.is-active {
    color: var(--accent-primary);
}

.nav-live-dot {
    position: absolute;
    top: 8px;
    right: calc(50% - 16px);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary);
}

/* ==========================================================
   CANVAS CHARTS & BEFORE/AFTER PHOTOS
   ========================================================== */
.chart-container {
    position: relative;
    width: 100%;
    margin: 0.4rem 0;
    touch-action: pan-y;
}

.chart-canvas {
    width: 100%;
    display: block;
}

.photo-compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
}

.photo-compare-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-align: center;
}

.photo-compare-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

/* Toggle Switch in Settings */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-color);
}

.toggle-row:last-child {
    border-bottom: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-input);
    border: 1px solid var(--border-strong);
    transition: 0.2s;
    border-radius: var(--radius-pill);
}

.slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: 0.2s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: var(--accent-primary-soft);
    border-color: var(--accent-primary);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
    background-color: var(--accent-primary);
}

/* ==========================================================
   LOGIN & SETUP AUTH PAGES
   ========================================================== */
.auth-body {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.2rem;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.setup-container {
    max-width: 540px;
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.6rem 1.4rem;
    box-shadow: var(--shadow-card);
}

.auth-header {
    text-align: center;
    margin-bottom: 1.4rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--accent-primary-soft);
    color: var(--accent-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.7rem;
}

.form-section-title {
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent-primary);
    margin: 1.1rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.86rem;
    color: var(--text-secondary);
    margin: 0.85rem 0 1.1rem;
    cursor: pointer;
}

.alert {
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.86rem;
}

.alert-danger {
    background: var(--accent-danger-soft);
    color: var(--accent-danger);
    border: 1px solid rgba(244, 63, 94, 0.35);
}

/* ==========================================================
   DOCTOR REPORT & PRINT / PDF OPTIMIZATION (/doctor-report)
   ========================================================== */
.doctor-report-body {
    background: #f8fafc;
    color: #0f172a;
    overflow: auto;
    height: auto;
}

.doctor-report-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1.2rem 3rem;
}

.doctor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #ffffff;
    padding: 0.8rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    margin-bottom: 1.2rem;
}

.doctor-period-pills,
.doctor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.doctor-header {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.1rem;
}

.doctor-badge {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #059669;
    margin-bottom: 0.25rem;
}

.doctor-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 1.15rem 1.3rem;
    margin-bottom: 1rem;
}

.doctor-section h2 {
    font-size: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.45rem;
    margin-bottom: 0.85rem;
}

.doctor-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.doctor-kpi-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.8rem;
}

.kpi-label {
    display: block;
    font-size: 0.74rem;
    color: #64748b;
}

.kpi-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 800;
    margin: 2px 0;
}

.kpi-sub {
    display: block;
    font-size: 0.74rem;
    color: #64748b;
}

.doctor-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.doctor-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.doctor-table th,
.doctor-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.doctor-table thead th {
    background: #f8fafc;
    font-weight: 700;
    color: #334155;
}

.doctor-note-box {
    margin-top: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

@media (max-width: 680px) {
    .doctor-kpi-grid { grid-template-columns: 1fr 1fr; }
    .doctor-two-col { grid-template-columns: 1fr; }
    .week-compare-grid { grid-template-columns: 1fr 1fr; }
}

@media print {
    .no-print { display: none !important; }
    body, .doctor-report-body { background: #ffffff !important; color: #000000 !important; }
    .doctor-report-container { max-width: 100%; padding: 0; }
    .doctor-section, .doctor-header { break-inside: avoid; box-shadow: none; border-color: #cbd5e1; }
}
