/* ===== PLONI FONT FAMILY ===== */
@font-face {
    font-family: 'Ploni';
    src: url('../fonts/Ploni-ULight.otf') format('opentype');
    font-weight: 200;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ploni';
    src: url('../fonts/Ploni-Light.otf') format('opentype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ploni';
    src: url('../fonts/Ploni-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ploni';
    src: url('../fonts/Ploni-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ploni';
    src: url('../fonts/Ploni-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ploni';
    src: url('../fonts/Ploni-Black.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ploni';
    src: url('../fonts/Ploni-UBold.otf') format('opentype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@tailwind base;
@tailwind components;
@tailwind utilities;

html, body {
    overflow-x: hidden !important;
    position: relative;
    margin: 0;
    padding: 0;
}

:root {
            /* ===== SURFACES & COLORS ===== */
            --bg-start: #0a0a0a;
            --bg-end: #000000;
            --panel-bg: rgba(15, 15, 15, 0.7);
            --card-bg: rgba(20, 20, 20, 0.6);
            --surface: rgba(255, 255, 255, 0.04);
            --text-primary: #ffffff;
            --text-secondary: #a3a3a3;
            --text-muted: #9ca3af; /* ≥4.5:1 on ~#141414 (was #737373 @ 3.89:1) */
            --border-color: rgba(255, 255, 255, 0.08);
            --border-light: rgba(255, 255, 255, 0.03);
            --brand-yellow: #38bdf8; /* Kept variable name for backwards compatibility, but it is now blue */
            --brand-dark: #0a0a0a;
            
            /* Accent Base */
            --accent-rgb: 56, 189, 248;
            --accent-soft: rgba(var(--accent-rgb), 0.15);
            --accent: var(--brand-yellow);
            --accent-hover: var(--brand-yellow);
            --input-bg: rgba(0, 0, 0, 0.4);

            /* ===== TYPE SCALE — Minor Third 1.2× (+ ui density step) ===== */
            --text-caption:    0.75rem;    /* 12px — meta, badges (min user-facing) */
            --text-small:      0.833rem;   /* ~13px — secondary labels, tags */
            --text-ui:         0.875rem;   /* 14px — dense planner/CRM chrome */
            --text-body:       1rem;       /* 16px — base body, inputs (iOS floor) */
            --text-subheading: 1.2rem;     /* ~19px — section titles, panel headers */
            --text-heading:    1.44rem;    /* ~23px — card headings, KPI values */
            --text-display:    1.728rem;   /* ~28px — page titles, hero numbers */
            --text-emphasis:   1.125rem;   /* 18px — macro totals, emphasized controls */
            --text-block-title: clamp(1.25rem, 2.2vw, 1.5rem);   /* program summary block */
            --text-stat-hero:   clamp(1.35rem, 2.5vw, 1.75rem); /* program summary KPI */
            --text-icon-lg:    2rem;       /* decorative icon glyphs (not body copy) */
            --text-unit-scale: 0.55em;     /* unit suffix relative to parent KPI (kg, %) */

            /* ===== FONT WEIGHTS ===== */
            --fw-normal: 400;
            --fw-medium: 500;
            --fw-semibold: 600;
            --fw-bold:   700;
            --fw-black:  900;

            /* ===== LINE HEIGHTS ===== */
            --lh-tight:   1.15;   /* Display / headings */
            --lh-snug:    1.3;    /* Subheadings, compact UI */
            --lh-normal:  1.5;    /* Body text (WCAG AA) */
            --lh-relaxed: 1.65;   /* Long-form content */

            /* ===== VERTICAL RHYTHM SPACING ===== */
            --space-xs: 0.25rem;  /* 4px */
            --space-sm: 0.5rem;   /* 8px */
            --space-md: 1rem;     /* 16px */
            --space-lg: 1.5rem;   /* 24px */
            --space-xl: 2rem;     /* 32px */

            /* ===== RADII & SHADOWS ===== */
            --radius-sm: 0.375rem;
            --radius-md: 0.5rem;
            --radius-lg: 0.75rem;
            --radius-xl: 1.25rem;
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
            --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.6);
            --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.8);
            --shadow-glow: 0 0 20px rgba(var(--accent-rgb), 0.15);
            --col-min: 220px;
        }

        body.light-mode {
            --bg-start: #f8fafc;
            --bg-end: #f1f5f9;
            --panel-bg: rgba(255, 255, 255, 0.9);
            --card-bg: rgba(255, 255, 255, 0.7);
            --surface: rgba(0, 0, 0, 0.03);
            --text-primary: #0f172a;
            --text-secondary: #64748b;
            --text-muted: #94a3b8;
            --border-color: rgba(0, 0, 0, 0.08);
            --border-light: rgba(0, 0, 0, 0.04);
            --accent: #ca8a04;
            --accent-soft: rgba(202, 138, 4, 0.08);
            --accent-hover: #a16207;
            --input-bg: rgba(255, 255, 255, 0.9);
            --radius-sm: 0.375rem;
            --radius-md: 0.5rem;
            --radius-lg: 0.75rem;
            --radius-xl: 1rem;
            --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
            --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
        }

        body {
            background-color: var(--bg-end);
            background-image: 
                radial-gradient(circle at 15% 50%, rgba(var(--accent-rgb), 0.03), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(var(--accent-rgb), 0.03), transparent 25%);
            color: var(--text-primary);
            background-attachment: fixed;
            min-height: 100vh;
            overflow-x: hidden;
            transition: background 0.5s ease, color 0.3s ease;
            font-family: 'Ploni', sans-serif;
            font-weight: var(--fw-normal);
            font-size: var(--text-body);
            line-height: var(--lh-normal);
            letter-spacing: normal;
            text-rendering: optimizeLegibility;
            font-kerning: normal;
        }
        *, *::before, *::after { 
            font-family: 'Ploni', sans-serif !important;
            text-rendering: optimizeLegibility;
        }
        h1,h2,h3,h4,h5,h6 {
            font-family: 'Ploni', sans-serif !important;
            color: var(--text-primary);
            line-height: var(--lh-tight);
            text-rendering: optimizeLegibility;
            font-kerning: normal;
        }
        h1 { font-size: var(--text-display); font-weight: var(--fw-bold); }
        h2 { font-size: var(--text-heading); font-weight: var(--fw-bold); }
        h3 { font-size: var(--text-subheading); font-weight: var(--fw-semibold); }
        h4 { font-size: var(--text-subheading); font-weight: var(--fw-semibold); }
        h5, h6 { font-size: var(--text-body); font-weight: var(--fw-medium); }
        
        /* Helper to isolate LTR values (numbers, decimals, percentages) in RTL contexts */
        .ltr-value {
            direction: ltr;
            display: inline-block;
            unicode-bidi: isolate;
        }
        
        /* Force bold numeric results */
        #out-proj-weight, 
        #nut-modifier-val, 
        #nut-timeline-val,
        #val-protein-ratio,
        #val-cf-split,
        #out-lbm,
        #out-tdee,
        #out-cals,
        #out-p,
        #out-c,
        #out-f,
        #activity-select-container .searchable-dropdown,
        #activity-select-container .searchable-dropdown *,
        #export-notes-training,
        #export-notes-nutrition,
        #export-client-name,
        #export-date,
        #export-client-meta,
        #export-biometrics-content span.text-heading,
        #export-biometrics-content .font-black,
        .font-assistant-800,
        #export-nutrition-content span.text-heading,
        #export-volume-content .font-black {
            font-weight: 800 !important;
        }
        
        /* ===== SECTION TITLES (panel headers like "User Profile", "יעדי נפח") ===== */
        .section-title {
            font-size: var(--text-heading);
            font-weight: var(--fw-black);
            letter-spacing: 0.02em;
            line-height: var(--lh-snug);
            color: var(--text-primary);
        }

        /* Semantic roles — prefer over stacking text-* + font-black (see typography-and-rhythm.md) */
        .text-role-title {
            font-size: var(--text-display);
            font-weight: var(--fw-bold);
            line-height: var(--lh-tight);
            color: var(--text-primary);
        }
        .text-role-section {
            font-size: var(--text-subheading);
            font-weight: var(--fw-semibold);
            line-height: var(--lh-snug);
            color: var(--text-primary);
        }
        .text-role-label {
            font-size: var(--text-small);
            font-weight: var(--fw-medium);
            line-height: var(--lh-snug);
            color: var(--text-secondary);
        }
        .text-role-body {
            font-size: var(--text-ui);
            font-weight: var(--fw-normal);
            line-height: var(--lh-normal);
            color: var(--text-primary);
        }
        .text-role-value {
            font-size: var(--text-body);
            font-weight: var(--fw-medium);
            line-height: var(--lh-normal);
            color: var(--text-primary);
        }
        .text-role-meta {
            font-size: var(--text-caption);
            font-weight: var(--fw-normal);
            line-height: var(--lh-snug);
            color: var(--text-secondary);
        }
        /* Hover / focus popup tooltips (`[data-tooltip]` → #global-tooltip) */
        .text-role-tooltip,
        #global-tooltip {
            font-family: 'Ploni', sans-serif;
            font-size: var(--text-ui);
            font-weight: var(--fw-normal);
            line-height: var(--lh-relaxed);
            letter-spacing: normal;
            color: var(--text-primary);
        }
        #global-tooltip {
            max-width: min(20rem, calc(100vw - 2rem));
            padding: 0.625rem 0.875rem;
            border-radius: var(--radius-lg, 0.75rem);
            background: rgba(12, 12, 12, 0.96);
            backdrop-filter: blur(12px);
            border: 1px solid rgba(255, 255, 255, 0.12);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.55);
        }
        #global-tooltip .tooltip-title {
            font-size: var(--text-ui);
            font-weight: var(--fw-semibold);
            line-height: var(--lh-snug);
            color: var(--text-primary);
        }
        #global-tooltip .tooltip-subline,
        #global-tooltip .tooltip-line-secondary {
            display: block;
            margin-top: 0.35rem;
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            line-height: var(--lh-snug);
            color: var(--text-secondary);
        }
        #global-tooltip .tooltip-subline--accent {
            color: rgba(var(--accent-rgb, 56, 189, 248), 0.92);
        }
        #global-tooltip .tooltip-subline--info {
            color: rgb(96 165 250 / 0.92);
        }
        #global-tooltip .tooltip-warn {
            color: rgb(251 146 60 / 0.95);
        }
        #global-tooltip strong,
        #global-tooltip b {
            font-weight: var(--fw-semibold);
            color: var(--text-primary);
        }
        .text-role-cta {
            font-size: var(--text-small);
            font-weight: var(--fw-bold);
            line-height: var(--lh-snug);
        }
        /* KPI / hero numbers (nutrition sliders, export totals) */
        .text-kpi {
            font-size: var(--text-heading);
            font-weight: var(--fw-bold);
            line-height: var(--lh-tight);
            color: var(--brand-yellow);
        }
        .text-kpi--on-dark {
            color: var(--text-primary);
        }

        input, select, textarea, button {
            font-family: 'Ploni', sans-serif;
            font-size: max(var(--text-body), 16px); /* Prevents iOS Safari auto-zoom */
            text-rendering: optimizeLegibility;
            font-kerning: normal;
        }
        
        /* Force bold weight for input fields */
        input[type="text"],
        input[type="number"],
        input[type="search"],
        input:not([type]),
        textarea {
            font-weight: 800 !important;
        }
        ::-webkit-scrollbar {
            width: 8px;
        }
        ::-webkit-scrollbar-track {
            background: rgba(38, 38, 38, 0.5);
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb {
            background: #525252;
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: #38bdf8;
        }
        .custom-scrollbar::-webkit-scrollbar {
            height: 6px;
        }
        .custom-scrollbar::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 10px;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb {
            background: rgba(var(--accent-rgb), 0.2);
            border-radius: 10px;
        }
        .custom-scrollbar:hover::-webkit-scrollbar-thumb {
            background: rgba(var(--accent-rgb), 0.5);
        }
        @keyframes slideUp {
            from { transform: translateY(100%); opacity: 0; }
            to { transform: translateY(0); opacity: 1; }
        }
        .toast-enter {
            animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        }
        
        /* ===== WEEKLY BOARD — Kanban Layout ===== */
        .weekly-board {
            display: grid;
            grid-template-columns: repeat(7, minmax(var(--col-min), 1fr));
            gap: 12px;
            min-height: 55vh;
            padding: 0 0 1rem 0;
        }
        @media (max-width: 1200px) {
            .weekly-board {
                grid-template-columns: repeat(7, minmax(200px, 1fr));
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                scroll-snap-type: x proximity;
                padding-bottom: 12px;
            }
        }
        @media (max-width: 768px) {
            .weekly-board {
                grid-template-columns: repeat(7, 85vw);
                scroll-snap-type: x mandatory;
            }
            .day-column { scroll-snap-align: center; }
        }

        .day-column {
            display: flex;
            flex-direction: column;
            background: var(--card-bg);
            backdrop-filter: blur(12px);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-xl);
            overflow: hidden;
            transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
            min-height: 350px;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), var(--shadow-sm);
        }
        .day-column:hover {
            border-color: rgba(var(--accent-rgb), 0.3);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), var(--shadow-lg), var(--shadow-glow);
            transform: translateY(-2px);
        }
        .day-column.is-rest {
            opacity: 0.55;
            border-style: dashed;
        }
        .day-column.drag-over {
            border-color: var(--accent) !important;
            box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-lg) !important;
            opacity: 1 !important;
        }

        .day-column-header {
            padding: 14px 16px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            cursor: grab;
            user-select: none;
            border-bottom: 1px solid var(--border-light);
            background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
            flex-shrink: 0;
            transition: background 0.2s;
        }
        .day-column-header:hover {
            background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, transparent 100%);
        }
        .day-column-header:active { cursor: grabbing; }

        .day-column-body {
            flex: 1;
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            overflow-y: auto;
            min-height: 0;
        }

        .day-column-footer {
            padding: 8px 10px;
            border-top: 1px solid var(--border-light);
            flex-shrink: 0;
        }

        /* ===== CONTROL BAR ===== */
        .control-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 12px 16px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--border-color);
            border-radius: 1rem;
            margin-bottom: 16px;
            flex-wrap: wrap;
            position: relative;
            z-index: 100; /* High z-index to keep dropdown above other content */
        }

        .volume-strip {
            display: flex;
            gap: 6px;
            padding: 12px 16px;
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            border: 1px solid var(--border-color);
            border-radius: 1rem;
            margin-bottom: 16px; /* Space below it before planner board */
            overflow-x: auto;
            flex-wrap: wrap;
            position: relative;
            z-index: 10; /* Stacks safely underneath control-bar popups */
        }

        /* ===== BULK EDIT ===== */
        .bulk-checkbox { display: none !important; }
        .bulk-edit-active .grab-handle { display: none !important; }
        .bulk-edit-active .bulk-checkbox { display: flex !important; }
        .bulk-edit-active .delete-btn { display: none !important; }

         .glass-panel {
             background: var(--panel-bg);
             backdrop-filter: blur(24px);
             -webkit-backdrop-filter: blur(24px);
             border: 1px solid var(--border-color);
             box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), var(--shadow-md);
             position: relative;
             z-index: 1;
             transition: z-index 0s, border-color 0.3s, box-shadow 0.3s;
         }
         .glass-panel:focus-within {
             z-index: 30;
         }
        
        .muscle-item {
            background: rgba(0, 0, 0, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.05);
            padding: 10px 12px;
            border-radius: var(--radius-lg);
            display: flex;
            align-items: center;
            gap: 10px;
            transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
            position: relative;
            overflow: hidden;
        }
        .muscle-item::before {
            content: '';
            position: absolute;
            inset: 0;
            background: linear-gradient(90deg, rgba(56,189,248,0) 0%, rgba(56,189,248,0.03) 50%, rgba(56,189,248,0) 100%);
            transform: translateX(-100%);
            transition: transform 0.4s ease;
        }
        .muscle-item:hover {
            border-color: rgba(var(--accent-rgb), 0.3);
            background: rgba(0, 0, 0, 0.4);
            transform: scale(1.01);
            box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        }
        .muscle-item:hover::before {
            transform: translateX(100%);
        }
        .vol-chip {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 14px;
            background: rgba(0, 0, 0, 0.4);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 2rem;
            font-size: var(--text-ui);
            font-weight: 600;
            white-space: nowrap;
            transition: all 0.2s ease;
        }
        .vol-chip:hover {
            border-color: rgba(var(--accent-rgb), 0.35);
        }

        .vol-summary-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 10px;
            border-radius: 999px;
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            background: rgba(255, 255, 255, 0.04);
            border: 1px solid rgba(255, 255, 255, 0.08);
            color: var(--text-secondary, rgba(255, 255, 255, 0.75));
        }
        .vol-summary-chip--ok    { background: rgba(34, 197, 94, 0.12);  border-color: rgba(34, 197, 94, 0.35);  color: #4ade80; }
        .vol-summary-chip--low   { background: rgba(234, 179, 8, 0.12);  border-color: rgba(234, 179, 8, 0.35);  color: #facc15; }
        .vol-summary-chip--high  { background: rgba(249, 115, 22, 0.12); border-color: rgba(249, 115, 22, 0.35); color: #fb923c; }
        .vol-summary-chip--ghost { background: rgba(120, 120, 120, 0.12);border-color: rgba(160, 160, 160, 0.25);color: rgba(255,255,255,0.6); }

        .vol-tile-status {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            line-height: 1.2;
        }

        .vol-tile {
            transition: border-color 200ms ease, box-shadow 200ms ease;
        }
        .vol-tile[data-status="optimal"] { box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.08) inset; }
        .vol-tile[data-status="over"]    { box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.10) inset; }
        .vol-tile[data-status="low"],
        .vol-tile[data-status="below_target"] { box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.10) inset; }
        
        /* Focus State Contrast */
        .glass-input:focus {
            background: rgba(0, 0, 0, 0.6);
            border-color: #38bdf8;
            box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.1);
        }
        
        /* Animation Utilities */
        .animate-in {
            animation-duration: 0.3s;
            animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
            animation-fill-mode: both;
        }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
        @keyframes slideInDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
        .fade-in { animation-name: fadeIn; }
        .slide-in-from-top-2 { animation-name: slideInDown; }
        
        /* Accessibility Contrast Check */
        .text-neutral-400 { color: #a3a3a3; } /* Meets 4.5:1 on #171717 */
        .text-neutral-500 { color: #737373; } /* Might be low, bump up where critical */
        
        /* Remove arrows from number input */
        input[type=number]::-webkit-inner-spin-button, 
        input[type=number]::-webkit-outer-spin-button { 
            -webkit-appearance: none; 
            margin: 0; 
        }
        /* Drag and Drop Helpers */
        body.dragging-active .day-column-body * {
            pointer-events: none;
        }
        
        .glass-panel {
            background: var(--panel-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--border-color);
            box-shadow: var(--shadow-md);
        }
        
        .glass-input {
            background: rgba(10, 10, 10, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.12);
            color: var(--text-primary);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            padding: 0.625rem 0.75rem;
            border-radius: var(--radius-lg);
            font-size: var(--text-body);
            line-height: var(--lh-normal);
            min-height: 40px;
            transition: border-color 0.2s ease, box-shadow 0.2s ease;
        }
        .glass-input:focus {
            background: var(--input-bg);
            border-color: var(--accent);
            box-shadow: 0 0 0 2px var(--accent-soft);
            outline: none;
        }

        /* CRM create-client modal — consistent field sizing */
        #create-client-modal .crm-form-input,
        #create-client-modal .dropdown-trigger {
            width: 100%;
            min-height: 44px;
        }
        #create-client-modal .searchable-dropdown,
        #edit-client-modal .searchable-dropdown {
            z-index: 60;
        }
        #create-client-modal .dropdown-menu,
        #edit-client-modal .dropdown-menu {
            z-index: 300;
        }
        #create-client-modal .searchable-dropdown.is-open,
        #edit-client-modal .searchable-dropdown.is-open {
            z-index: 70;
        }
        #create-client-modal .dropdown-trigger .selected-text,
        #edit-client-modal .dropdown-trigger .selected-text {
            font-size: var(--text-ui);
            font-weight: var(--fw-semibold);
        }

        /* Program summary — header card (compact) */
        #program-summary-view .ps-header-compact {
            display: grid;
            gap: 0.65rem 1rem;
            align-items: end;
            grid-template-columns: 1fr;
            grid-template-areas:
                "identity"
                "meta"
                "nav";
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-header-compact {
                grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
                grid-template-areas: "identity meta nav";
                gap: 0.75rem 1.5rem;
                align-items: center;
            }
        }
        #program-summary-view .ps-header-identity {
            grid-area: identity;
            min-width: 0;
            text-align: right;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-header-identity {
                justify-self: start;
            }
        }
        #program-summary-view .ps-client-line {
            font-size: var(--text-small);
            font-weight: 700;
            color: var(--text-secondary);
            margin: 0 0 0.25rem;
            line-height: 1.25;
        }
        #program-summary-view .ps-block-title {
            margin: 0;
            font-size: var(--text-block-title);
            font-weight: 900;
            line-height: 1.2;
            color: #fff;
            letter-spacing: -0.02em;
        }
        #program-summary-view .ps-header-title-row {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: flex-start;
            gap: 0.55rem 0.65rem;
        }
        #program-summary-view .ps-strategy {
            margin: 0.2rem 0 0;
            line-height: 1.3;
        }
        #program-summary-view .ps-meta-strip {
            grid-area: meta;
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 0.5rem 0.85rem;
            width: 100%;
            max-width: 22rem;
            margin-inline: auto;
        }
        @media (min-width: 640px) {
            #program-summary-view .ps-meta-strip {
                grid-template-columns: repeat(3, minmax(7.5rem, 1fr));
                max-width: 30rem;
            }
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-meta-strip {
                width: max-content;
                max-width: min(32rem, 100%);
                margin-inline: 0;
                justify-self: center;
            }
        }
        #program-summary-view .ps-header-nav {
            grid-area: nav;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-header-nav {
                justify-self: end;
            }
        }
        #program-summary-view .ps-status-pill {
            display: inline-flex;
            align-items: center;
            padding: 0.3rem 0.75rem;
            border-radius: 999px;
            font-size: var(--text-small);
            font-weight: var(--fw-bold);
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(0, 0, 0, 0.35);
            white-space: nowrap;
        }
        #program-summary-view .ps-status-pill--active {
            color: var(--brand-yellow, #38bdf8);
            border-color: rgba(56, 189, 248, 0.35);
            background: rgba(56, 189, 248, 0.1);
        }
        #program-summary-view .ps-status-pill--inactive {
            color: var(--text-secondary);
        }
        #program-summary-view .ps-header-nav {
            display: flex;
            flex-wrap: wrap;
            gap: 0.4rem;
            flex-shrink: 0;
            justify-content: flex-start;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-header-nav {
                flex-direction: column;
                align-items: stretch;
                min-width: 9.5rem;
            }
        }
        #program-summary-view .ps-header-chip {
            display: inline-flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.35rem;
            padding: 0.35rem 0.65rem;
            border-radius: 0.5rem;
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            color: #fff;
            background: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(255, 255, 255, 0.1);
            transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
        }
        #program-summary-view .ps-header-chip:hover {
            background: rgba(56, 189, 248, 0.12);
            border-color: rgba(56, 189, 248, 0.35);
            color: var(--brand-yellow, #38bdf8);
        }

        /* Program summary — date / duration meta fields */
        #program-summary-view .ps-header-card .ps-meta-label {
            display: block;
            margin-bottom: 0.3rem;
        }
        #program-summary-view .ps-header-card .ps-meta-input {
            width: 100%;
            min-height: 38px;
            padding-top: 0.4rem;
            padding-bottom: 0.4rem;
            font-size: var(--text-small);
            font-weight: 700;
        }
        #program-summary-view .ps-meta-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 1rem 1.25rem;
            width: 100%;
            max-width: 32rem;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-meta-grid {
                grid-template-columns: repeat(4, minmax(0, 1fr));
                max-width: none;
            }
        }
        #program-summary-view .ps-meta-label {
            display: block;
            margin-bottom: 0.5rem;
        }
        #program-summary-view .ps-meta-label,
        #program-summary-view .ps-stat-label,
        #program-summary-view .ps-detail-title,
        #program-summary-view .ps-week-day-label,
        #program-summary-view .ps-macro-name {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
            letter-spacing: normal;
            text-transform: none;
        }
        #program-summary-view .ps-meta-input {
            width: 100%;
            min-height: 44px;
            font-size: var(--text-small);
            font-weight: 700;
        }
        #program-summary-view .ps-meta-input--narrow {
            width: 4.5rem;
            min-width: 4.5rem;
        }
        #program-summary-view .ps-meta-inline {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        #program-summary-view .ps-meta-suffix {
            font-size: var(--text-caption);
            font-weight: 700;
            color: var(--text-secondary);
            white-space: nowrap;
        }
        #program-summary-view .ps-meta-status {
            display: flex;
            align-items: center;
            min-height: 44px;
            font-size: var(--text-small);
            font-weight: 800;
        }

        /* Planner — cloud save status */
        .planner-save-status {
            display: inline-flex;
            align-items: center;
            gap: 0.4rem;
            padding: 0.35rem 0.65rem;
            border-radius: 999px;
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(0, 0, 0, 0.35);
            color: var(--text-secondary);
            max-width: 14rem;
            line-height: 1.2;
        }
        .planner-save-status::before {
            content: '';
            width: 7px;
            height: 7px;
            border-radius: 50%;
            background: currentColor;
            flex-shrink: 0;
        }
        .planner-save-status[data-status="cloud"] {
            color: var(--brand-yellow, #38bdf8);
            border-color: rgba(56, 189, 248, 0.35);
            background: rgba(56, 189, 248, 0.08);
        }
        .planner-save-status[data-status="saving"],
        .planner-save-status[data-status="pending"] {
            color: rgb(250 204 21);
            border-color: rgba(250, 204, 21, 0.3);
        }
        .planner-save-status[data-status="local"] {
            color: var(--text-secondary);
        }
        .planner-save-status[data-status="auth"],
        .planner-save-status[data-status="error"] {
            color: rgb(248 113 113);
            border-color: rgba(248, 113, 113, 0.35);
            background: rgba(248, 113, 113, 0.08);
        }

        /* Program summary — section cards (hero + detail) */
        #program-summary-view .ps-section-body {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
        }
        #program-summary-view .ps-section-banner {
            font-size: var(--text-caption);
            font-weight: 700;
            margin: 0;
            line-height: 1.35;
        }
        #program-summary-view .ps-section-banner--draft {
            color: rgb(251 191 36 / 0.95);
        }
        #program-summary-view .ps-hero-grid {
            display: grid;
            gap: 0.65rem;
        }
        #program-summary-view .ps-hero-grid--nutrition {
            grid-template-columns: 1fr;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-hero-grid--nutrition {
                grid-template-columns: 2fr 1fr 1fr;
            }
        }
        #program-summary-view .ps-hero-grid--workout {
            grid-template-columns: 1fr 1fr;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-hero-grid--workout {
                grid-template-columns: 1fr 1fr 1.35fr;
            }
        }
        #program-summary-view .ps-stat-tile {
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.06);
            border-radius: 0.75rem;
            padding: 0.85rem 1rem;
            display: flex;
            flex-direction: column;
            justify-content: center;
            gap: 0.2rem;
            min-height: 4.5rem;
        }
        #program-summary-view .ps-stat-hero {
            border-color: rgba(56, 189, 248, 0.2);
            background: linear-gradient(135deg, rgba(56, 189, 248, 0.08), rgba(0, 0, 0, 0.35));
        }
        #program-summary-view .ps-stat-tile--stack {
            gap: 0.15rem;
        }
        #program-summary-view .ps-stat-label--secondary {
            margin-top: 0.35rem;
        }
        #program-summary-view .ps-stat-value {
            font-size: var(--text-stat-hero);
            font-weight: var(--fw-black);
            line-height: 1.1;
            color: #fff;
        }
        #program-summary-view .ps-stat-value--hero {
            color: var(--brand-yellow, #38bdf8);
        }
        #program-summary-view .ps-stat-value--accent {
            color: var(--brand-yellow, #38bdf8);
        }
        #program-summary-view .ps-stat-value--text {
            font-size: var(--text-body);
            font-weight: var(--fw-bold);
            line-height: 1.25;
        }
        #program-summary-view .ps-stat-value--sm {
            font-size: var(--text-small);
            color: rgb(212 212 212);
        }
        #program-summary-view .ps-stat-unit {
            font-size: var(--text-unit-scale);
            font-weight: var(--fw-semibold);
            color: var(--text-secondary);
            margin-inline-start: 0.2em;
        }
        #program-summary-view .ps-stat-sub {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
            line-height: 1.35;
            margin-top: 0.15rem;
        }
        #program-summary-view .ps-detail-panel {
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.06);
            border-radius: 0.75rem;
            padding: 0.85rem 1rem;
        }
        #program-summary-view .ps-detail-title {
            display: block;
            margin-bottom: 0.65rem;
        }
        #program-summary-view .ps-volume-chips {
            display: flex;
            flex-wrap: wrap;
            gap: 0.5rem;
        }
        #program-summary-view .ps-week-board {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 0.5rem;
        }
        @media (min-width: 640px) {
            #program-summary-view .ps-week-board {
                grid-template-columns: repeat(4, minmax(0, 1fr));
            }
        }
        @media (min-width: 1024px) {
            #program-summary-view .ps-week-board {
                grid-template-columns: repeat(7, minmax(0, 1fr));
            }
        }
        #program-summary-view .ps-week-day {
            background: rgba(0, 0, 0, 0.35);
            border: 1px solid rgba(255, 255, 255, 0.06);
            border-radius: 0.65rem;
            padding: 0.55rem 0.5rem;
            min-height: 5rem;
            display: flex;
            flex-direction: column;
            gap: 0.4rem;
        }
        #program-summary-view .ps-week-day:not(.is-rest) {
            border-color: rgba(255, 255, 255, 0.1);
            background: rgba(0, 0, 0, 0.4);
        }
        #program-summary-view .ps-week-day.is-rest {
            opacity: 0.6;
            border-style: dashed;
        }
        #program-summary-view .ps-week-day-head {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.35rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.07);
            padding-bottom: 0.35rem;
        }
        #program-summary-view .ps-week-day-label {
            font-size: var(--text-caption);
            font-weight: var(--fw-bold);
            color: #fff;
            line-height: 1.2;
        }
        #program-summary-view .ps-day-count {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            color: var(--brand-yellow, #38bdf8);
            white-space: nowrap;
        }
        #program-summary-view .ps-day-count .ltr-value {
            font-weight: var(--fw-black);
        }
        #program-summary-view .ps-week-day-body {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            gap: 0.3rem;
        }
        #program-summary-view .ps-week-day-body.is-rest-body {
            align-items: center;
            justify-content: center;
        }
        #program-summary-view .ps-week-item {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 0.4rem;
        }
        #program-summary-view .ps-week-item-name {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            color: #fff;
            line-height: 1.25;
        }
        #program-summary-view .ps-week-item-sets {
            font-size: var(--text-caption);
            font-weight: var(--fw-bold);
            color: var(--text-secondary);
            background: rgba(255, 255, 255, 0.06);
            border-radius: 0.35rem;
            padding: 0.05rem 0.35rem;
            white-space: nowrap;
        }
        #program-summary-view .ps-week-event {
            display: flex;
            align-items: flex-start;
            gap: 0.35rem;
            background: rgba(56, 189, 248, 0.1);
            border: 1px solid rgba(56, 189, 248, 0.28);
            border-radius: 0.45rem;
            padding: 0.3rem 0.4rem;
        }
        #program-summary-view .ps-week-event-icon {
            width: 0.85rem;
            height: 0.85rem;
            color: var(--brand-yellow, #38bdf8);
            flex-shrink: 0;
            margin-top: 0.1rem;
        }
        #program-summary-view .ps-week-event-text {
            display: flex;
            flex-direction: column;
            gap: 0.05rem;
            min-width: 0;
        }
        #program-summary-view .ps-week-event-name {
            font-size: var(--text-caption);
            font-weight: var(--fw-bold);
            color: var(--brand-yellow, #38bdf8);
            line-height: 1.2;
        }
        #program-summary-view .ps-week-event-desc {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
            line-height: 1.25;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        #program-summary-view .ps-week-rest {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
        }
        #program-summary-view .ps-detail-head {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 0.5rem;
            margin-bottom: 0.65rem;
        }
        #program-summary-view .ps-detail-head .ps-detail-title {
            margin-bottom: 0;
        }
        #program-summary-view .ps-detail-meta {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            color: var(--text-secondary);
            white-space: nowrap;
        }
        #program-summary-view .ps-detail-meta--event {
            color: var(--brand-yellow, #38bdf8);
        }
        /* Volume chips with target status */
        #program-summary-view .ps-vol-chip {
            gap: 0.45rem;
        }
        #program-summary-view .ps-vol-dot {
            width: 0.5rem;
            height: 0.5rem;
            border-radius: 999px;
            flex-shrink: 0;
            background: #9ca3af;
        }
        #program-summary-view .ps-vol-name {
            color: #fff;
            font-weight: var(--fw-bold);
        }
        #program-summary-view .ps-vol-value {
            font-weight: var(--fw-bold);
            color: var(--text-secondary);
        }
        #program-summary-view .ps-vol--low .ps-vol-dot { background: #f87171; }
        #program-summary-view .ps-vol--low .ps-vol-value { color: #f87171; }
        #program-summary-view .ps-vol--optimal .ps-vol-dot { background: #4ade80; }
        #program-summary-view .ps-vol--optimal .ps-vol-value { color: #4ade80; }
        #program-summary-view .ps-vol--high .ps-vol-dot { background: #fb923c; }
        #program-summary-view .ps-vol--high .ps-vol-value { color: #fb923c; }
        #program-summary-view .ps-vol--none .ps-vol-dot { background: #9ca3af; }
        #program-summary-view .ps-vol-legend {
            display: flex;
            flex-wrap: wrap;
            gap: 0.85rem;
            margin-top: 0.75rem;
            padding-top: 0.6rem;
            border-top: 1px solid rgba(255, 255, 255, 0.07);
        }
        #program-summary-view .ps-vol-legend-item {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            color: var(--text-secondary);
        }
        #program-summary-view .ps-section-cta {
            align-self: flex-start;
            font-size: var(--text-small);
            font-weight: var(--fw-bold);
            color: var(--brand-yellow, #38bdf8);
            background: none;
            border: none;
            padding: 0;
            cursor: pointer;
            text-decoration: none;
        }
        #program-summary-view .ps-section-cta:hover {
            text-decoration: underline;
        }

        /* Program summary — macro breakdown (detail panel) */
        #program-summary-view .ps-macro-layout {
            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
            gap: 1rem 1.5rem;
            width: 100%;
        }
        #program-summary-view .ps-macro-rows {
            flex: 1 1 0;
            min-width: 0;
            width: 100%;
            max-width: none;
            display: flex;
            flex-direction: column;
            gap: 0.55rem;
        }
        #program-summary-view .ps-macro-donut-wrap {
            flex: 0 0 auto;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0.15rem;
        }
        #program-summary-view .ps-macro-donut {
            width: 5.25rem;
            height: 5.25rem;
            border-radius: 50%;
            position: relative;
            box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-macro-donut {
                width: 6.75rem;
                height: 6.75rem;
            }
        }
        #program-summary-view .ps-macro-donut-hole {
            position: absolute;
            inset: 11px;
            border-radius: 50%;
            background: rgb(10 10 10 / 0.94);
            border: 1px solid rgba(255, 255, 255, 0.08);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            line-height: 1;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-macro-donut-hole {
                inset: 14px;
            }
        }
        #program-summary-view .ps-macro-donut-label {
            font-size: var(--text-ui);
            font-weight: var(--fw-black);
            color: #fff;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-macro-donut-label {
                font-size: var(--text-subheading);
            }
        }
        #program-summary-view .ps-macro-donut-sub {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
            margin-top: 2px;
        }
        @media (min-width: 768px) {
            #program-summary-view .ps-macro-donut-sub {
                font-size: var(--text-caption);
            }
        }
        #program-summary-view .ps-macro-row {
            display: flex;
            align-items: flex-start;
            gap: 0.5rem;
            width: 100%;
        }
        #program-summary-view .ps-macro-icon-wrap {
            width: 2rem;
            height: 2rem;
            border-radius: 0.55rem;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        #program-summary-view .ps-macro-icon-wrap svg {
            width: 1.2rem;
            height: 1.2rem;
        }
        #program-summary-view .ps-macro-icon-wrap.ps-macro--protein {
            background: rgba(239, 68, 68, 0.14);
            color: #f87171;
        }
        #program-summary-view .ps-macro-icon-wrap.ps-macro--carbs {
            background: rgba(56, 189, 248, 0.14);
            color: #38bdf8;
        }
        #program-summary-view .ps-macro-icon-wrap.ps-macro--fat {
            background: rgba(192, 132, 252, 0.14);
            color: #c084fc;
        }
        #program-summary-view .ps-macro--protein {
            color: #f87171;
        }
        #program-summary-view .ps-macro--carbs {
            color: #38bdf8;
        }
        #program-summary-view .ps-macro--fat {
            color: #c084fc;
        }
        #program-summary-view .ps-macro-row-body {
            flex: 1 1 0;
            min-width: 0;
            width: 100%;
        }
        #program-summary-view .ps-macro-row-head {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 0.75rem;
            margin-bottom: 0.35rem;
        }
        #program-summary-view .ps-macro-name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        #program-summary-view .ps-macro-val {
            display: inline-flex;
            align-items: baseline;
            gap: 0.3rem;
            flex-shrink: 0;
            white-space: nowrap;
        }
        #program-summary-view .ps-macro-num {
            font-size: var(--text-emphasis);
            font-weight: var(--fw-black);
            color: #fff;
            font-variant-numeric: tabular-nums;
            line-height: 1;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
        }
        #program-summary-view .ps-macro-val.ps-macro--protein .ps-macro-num {
            color: #fecaca;
        }
        #program-summary-view .ps-macro-val.ps-macro--carbs .ps-macro-num {
            color: #bae6fd;
        }
        #program-summary-view .ps-macro-val.ps-macro--fat .ps-macro-num {
            color: #e9d5ff;
        }
        #program-summary-view .ps-macro-unit {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: rgb(212 212 212);
            line-height: 1;
        }
        #program-summary-view .ps-macro-bar {
            width: 100%;
            height: 4px;
            border-radius: 999px;
            background: rgba(255, 255, 255, 0.06);
            overflow: hidden;
        }
        #program-summary-view .ps-macro-bar-fill {
            height: 100%;
            border-radius: 999px;
            transition: width 0.35s ease;
        }
        #program-summary-view .ps-macro-bar-fill.ps-macro--protein {
            background: linear-gradient(90deg, #ef4444, #f87171);
        }
        #program-summary-view .ps-macro-bar-fill.ps-macro--carbs {
            background: linear-gradient(90deg, #2563eb, #38bdf8);
        }
        #program-summary-view .ps-macro-bar-fill.ps-macro--fat {
            background: linear-gradient(90deg, #a855f7, #c084fc);
        }
        #program-summary-view .ps-macro-pct {
            display: block;
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
            margin-top: 0.25rem;
            text-align: end;
        }
        
        .btn-primary {
            background: linear-gradient(135deg, var(--accent), var(--accent-hover));
            color: #171717;
            transition: all 0.2s ease;
            border-radius: var(--radius-lg);
        }
        .btn-primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.25);
        }
        
        .hide-scrollbar {
            -ms-overflow-style: none;
            scrollbar-width: none;
        }

        .muscle-item {
            background: rgba(0, 0, 0, 0.6); /* Much darker solid base for text to pop */
            border: 1px solid rgba(255, 255, 255, 0.18); /* Brighter border definition */
            border-radius: 0.75rem;
            padding: 10px 12px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            transition: all 0.2s ease;
            cursor: grab;
        }
        .muscle-item:hover {
            border-color: rgba(var(--accent-rgb), 0.3);
            box-shadow: var(--shadow-sm);
        }
        .muscle-item:active { cursor: grabbing; }

        /* Group card — wraps child muscles */
        .group-card {
            background: rgba(0, 0, 0, 0.5); /* Deeper, cleaner contrasting background */
            border: 1px solid rgba(255, 255, 255, 0.18);
            border-radius: 0.75rem;
            overflow: hidden;
            transition: border-color 0.2s ease;
        }
        .group-card:hover {
            border-color: rgba(var(--accent-rgb), 0.35);
        }
        .group-card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 12px;
            background: rgba(255, 255, 255, 0.05); /* Strong defined header separation */
            border-bottom: 1px solid rgba(255, 255, 255, 0.12);
            cursor: grab;
        }
        .group-card-header:active { cursor: grabbing; }
        .group-card-child {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 8px 12px;
        }
        .group-card-child + .group-card-child {
            border-top: 1px solid var(--border-light);
        }

        /* ===== WEEKLY PLANNER TYPOGRAPHY (.planner-weekly) ===== */
        .planner-weekly #view-split .text-neutral-500,
        .planner-weekly #view-split .text-neutral-400,
        .planner-weekly #planner-client-bar .text-neutral-500 {
            color: var(--text-secondary);
        }
        .planner-weekly #planner-client-bar .text-role-label,
        .planner-weekly #planner-client-bar .text-role-value,
        #hub-client-bar-mount #planner-client-bar .text-role-label,
        #hub-client-bar-mount #planner-client-bar .text-role-value {
            display: block;
        }
        .planner-weekly .planner-nav-link {
            font-size: var(--text-ui);
            font-weight: var(--fw-semibold);
        }
        .planner-weekly .planner-palette-search {
            font-size: var(--text-subheading);
            font-weight: var(--fw-semibold);
            line-height: var(--lh-snug);
        }
        .planner-weekly .planner-summary-text {
            font-size: var(--text-ui);
            font-weight: var(--fw-normal);
            line-height: var(--lh-relaxed);
            color: var(--text-secondary);
            font-family: 'Ploni', sans-serif;
        }
        .planner-weekly #bulk-action-bar {
            font-size: var(--text-ui);
        }
        .planner-weekly .planner-chart-label {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
        }
        .planner-weekly .planner-chart-target {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            color: rgba(var(--accent-rgb), 0.85);
        }
        .planner-weekly .planner-chart-hover {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            color: #fff;
        }
        .planner-weekly .planner-status-badge {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
        }
        .planner-weekly #view-split .planner-targets-label {
            font-size: var(--text-subheading);
            font-weight: var(--fw-semibold);
            color: var(--text-secondary);
        }
        .planner-weekly #view-split .planner-targets-badge {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
        }
        .planner-weekly #view-split .volume-legend-item {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
        }
        .planner-weekly #view-split .day-sets-total {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
        }
        .planner-weekly #view-split .vol-chip-name {
            font-size: var(--text-ui);
            font-weight: var(--fw-medium);
            color: var(--text-primary);
        }
        .planner-weekly #view-split .vol-chip-value {
            font-size: var(--text-body);
            font-weight: var(--fw-semibold);
        }
        .planner-weekly #view-split .planner-muscle-name {
            font-size: var(--text-ui);
            font-weight: var(--fw-semibold);
            color: var(--text-primary);
        }
        .planner-weekly #view-split .group-card-child .planner-muscle-name {
            font-size: var(--text-small);
        }
        .planner-weekly #view-split .planner-group-name {
            font-size: var(--text-ui);
            font-weight: var(--fw-semibold);
            color: var(--text-primary);
        }
        .planner-weekly #view-split input.planner-group-name {
            border: 1px solid transparent;
            border-radius: 0.5rem;
            padding: 0.125rem 0.375rem;
            margin: -0.125rem -0.375rem;
            transition: border-color 0.15s ease, background-color 0.15s ease;
        }
        .planner-weekly #view-split input.planner-group-name:hover,
        .planner-weekly #view-split input.planner-group-name:focus {
            border-color: rgba(255, 255, 255, 0.15);
            background-color: rgba(0, 0, 0, 0.25);
        }
        .planner-weekly #view-split .planner-sets-input {
            font-size: var(--text-ui);
            font-weight: var(--fw-bold);
        }
        .planner-weekly #view-split .planner-sets-label {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
        }
        .planner-weekly #view-split .planner-macro-sets {
            font-size: var(--text-ui);
            font-weight: var(--fw-bold);
        }
        .planner-weekly #view-split .planner-event-title {
            font-size: var(--text-ui);
            font-weight: var(--fw-semibold);
            color: var(--brand-yellow);
        }
        .planner-weekly #view-split .planner-event-notes {
            font-size: var(--text-small);
            font-weight: var(--fw-normal);
            color: var(--text-secondary);
        }
        .planner-weekly #view-split .planner-footer-btn {
            font-size: var(--text-ui);
            font-weight: var(--fw-medium);
        }
        .planner-weekly #view-split .planner-toolbar-btn {
            font-size: var(--text-small);
            font-weight: var(--fw-semibold);
        }
        .planner-weekly #view-split .planner-toolbar-btn--muted {
            font-weight: var(--fw-medium);
            color: var(--text-secondary);
        }

        /* RTL/LTR adjustments */
        html[dir="rtl"] .mr-2 { margin-right: 0.5rem; margin-left: 0; }
        html[dir="rtl"] .-mr-10 { margin-right: -2.5rem; margin-left: 0; }
        html[dir="rtl"] .right-0 { right: 0; left: auto; }
        
        html[dir="ltr"] .mr-2 { margin-right: 0; margin-left: 0.5rem; }
        html[dir="ltr"] .-mr-10 { margin-right: 0; margin-left: -2.5rem; }
        /* Do not remap .right-0 globally in LTR — breaks #library-sidebar */
        
        /* Premium Select Menu Styling */
        select {
            appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23facc15' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7' /%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: left 1rem center;
            background-size: 1.25rem;
            padding-left: 3rem !important;
            box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
        }
        body.light-mode select {
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23ca8a04' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7' /%3E%3C/svg%3E");
        }
        html[dir="ltr"] select {
            background-position: right 1rem center;
            padding-left: 1rem !important;
            padding-right: 3rem !important;
        }
        select option {
            background-color: var(--bg-start);
            color: var(--text-primary);
            padding: 12px;
        }
        
        /* Command Palette Styles */
        #command-palette {
            background: rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(8px);
            display: none;
            z-index: 1000;
        }
        #command-palette .palette-content {
            background: var(--panel-bg);
            border: 1px solid var(--border-color);
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            max-width: 600px;
            width: 90%;
            margin-top: 10vh;
        }
        .palette-item {
            padding: 0.75rem 1rem;
            border-radius: 0.75rem;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            color: var(--text-secondary);
            font-size: var(--text-ui);
            font-weight: var(--fw-medium);
            line-height: var(--lh-snug);
        }
        .palette-item .palette-kbd {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-muted);
        }
        .palette-item.active, .palette-item:hover {
            background: var(--accent-soft);
            color: var(--accent);
        }
        
        /* Template Sidebar (Drawer) */
        #template-sidebar {
            position: fixed;
            top: 0;
            left: -400px;
            width: 400px;
            max-width: 90vw;
            height: 100vh;
            background: rgba(10, 10, 10, 0.97);
            backdrop-filter: blur(40px);
            z-index: 1100;
            transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            border-right: 1px solid var(--border-color);
            box-shadow: 20px 0 50px rgba(0, 0, 0, 0.7);
            display: flex;
            flex-direction: column;
        }
        #template-sidebar.open {
            left: 0;
        }
        #sidebar-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            backdrop-filter: blur(4px);
            z-index: 1050;
            display: none;
            opacity: 0;
            transition: opacity 0.4s ease;
        }
        #sidebar-overlay.visible {
            display: block;
            opacity: 1;
        }
        body.library-dragging #sidebar-overlay {
            pointer-events: none;
        }

        /* Muscle library drawer — physical right edge (do not use Tailwind right-0; see LTR note above) */
        #library-sidebar {
            position: fixed;
            top: 0;
            right: 0;
            left: auto;
            width: 20rem;
            height: 100%;
            z-index: 2001;
            display: flex;
            flex-direction: column;
            background: rgb(23 23 23);
            border-left: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            transform: translateX(100%);
        }
        #library-sidebar.is-open {
            transform: translateX(0);
        }

        /* Edit client modal — no inner scroll; portal menus escape the panel */
        #edit-client-modal .modal-content {
            overflow: visible;
            max-height: none;
        }
        #edit-client-modal .edit-client-form-fields {
            overflow: visible;
        }
        @media (max-width: 480px) {
            #edit-client-modal .modal-content {
                padding: 1.25rem;
            }
            #edit-client-modal .edit-client-form-fields {
                gap: 0.875rem;
            }
        }
        #hub-client-bar-mount .client-bar-panel,
        .planner-weekly #planner-client-bar.client-bar-panel {
            cursor: pointer;
        }
        .dropdown-menu--portal {
            z-index: 10050;
        }
        .dropdown-menu--portal.dropdown-menu--portal-up {
            transform-origin: bottom;
        }
        .dropdown-menu--portal.dropdown-menu--portal-up.show {
            transform: scale(1) translateY(0);
        }
        /* Settings menu (hub + planner header) */
        .settings-dropdown {
            position: absolute;
            inset-inline-end: 0;
            top: calc(100% + 0.35rem);
            z-index: 60;
            display: flex;
            flex-direction: column;
            gap: 0.15rem;
            min-width: 13rem;
            max-width: min(16rem, calc(100vw - 1.5rem));
            padding: 0.35rem;
            border-radius: 0.75rem;
            border: 1px solid rgba(255, 255, 255, 0.14);
            background: rgba(10, 10, 10, 0.97);
            backdrop-filter: blur(24px);
            box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
        }
        body.light-mode .settings-dropdown {
            background: rgba(255, 255, 255, 0.98);
            border-color: #e5e7eb;
            box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
        }
        .settings-dropdown.hidden {
            display: none;
        }
        .settings-dropdown__row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            width: 100%;
            padding: 0.6rem 0.75rem;
            border: none;
            border-radius: 0.5rem;
            background: transparent;
            color: var(--text-primary);
            text-align: start;
            cursor: pointer;
            transition: background 0.15s ease;
        }
        .settings-dropdown__row:hover {
            background: rgba(255, 255, 255, 0.07);
        }
        body.light-mode .settings-dropdown__row:hover {
            background: rgba(15, 23, 42, 0.06);
        }
        .settings-dropdown__row--label {
            cursor: pointer;
        }
        .settings-dropdown__row--danger {
            color: #f87171;
        }
        .settings-dropdown__row--danger:hover {
            background: rgba(239, 68, 68, 0.12);
        }
        .settings-dropdown__icon {
            flex-shrink: 0;
            font-size: var(--text-body);
            line-height: 1;
            opacity: 0.75;
        }
        .settings-dropdown__icon--picker {
            display: inline-flex;
            align-items: center;
            gap: 0.35rem;
        }
        .settings-dropdown__icon--picker input[type="color"] {
            width: 1.35rem;
            height: 1.35rem;
            padding: 0;
            border: none;
            border-radius: 999px;
            cursor: pointer;
            background: transparent;
        }
        .settings-dropdown__divider {
            height: 1px;
            margin: 0.1rem 0.35rem;
            background: rgba(255, 255, 255, 0.1);
        }
        body.light-mode .settings-dropdown__divider {
            background: #e5e7eb;
        }
        @media (max-width: 639px) {
            .settings-dropdown {
                inset-inline-end: 0;
                min-width: min(13rem, calc(100vw - 1.25rem));
            }
        }

        /* Searchable Dropdown Styles */
        .searchable-dropdown {
            position: relative;
            width: 100%;
            z-index: 50;
        }
        .dropdown-chevron.rotate-180 {
            transform: rotate(180deg);
        }
        .dropdown-trigger {
            width: 100%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .dropdown-menu {
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            right: 0;
            background: rgba(12, 12, 12, 0.98);
            backdrop-filter: blur(25px);
            border: 1px solid rgba(255, 255, 255, 0.15);
            border-radius: 1rem;
            z-index: 200;
            display: flex; /* Controlled via scale/opacity */
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.75);
            max-height: 300px;
            
            /* Smooth micro-animation state defaults */
            opacity: 0;
            visibility: hidden;
            transform: scale(0.95) translateY(-10px);
            transform-origin: top;
            transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), 
                        visibility 0.2s;
        }
        
        /* Specifically for day footer - open upward "drop-up" style to stay inside view */
        .day-column-footer .dropdown-menu {
            top: auto;
            bottom: calc(100% + 12px);
            transform: scale(0.95) translateY(10px);
            transform-origin: bottom;
        }

        .dropdown-menu.show {
            opacity: 1;
            visibility: visible;
            transform: scale(1) translateY(0);
        }
        .dropdown-search {
            padding: 0.75rem;
            border-bottom: 1px solid var(--border-color);
        }
        .dropdown-list {
            overflow-y: auto;
            padding: 0.5rem;
            flex: 1;
            min-height: 0;
        }
        .dropdown-item {
            padding: 0.625rem 1rem;
            border-radius: 0.625rem;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            gap: 0.75rem;
            color: var(--text-primary);
            font-weight: 600;
            font-size: var(--text-ui);
        }
        .dropdown-item:hover, .dropdown-item.focused {
            background: rgba(var(--accent-rgb), 0.12);
            color: var(--accent);
        }
        .dropdown-item.selected {
            background: var(--accent);
            color: black;
        }

        /* Rest day CTA */
        .rest-cta {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            flex: 1;
            gap: 8px;
            opacity: 0.5;
        }
        .rest-cta span.rest-icon { font-size: var(--text-icon-lg); }
        .rest-cta span.rest-label {
            font-size: var(--text-caption);
            font-weight: var(--fw-bold);
            text-transform: uppercase;
            letter-spacing: 0.02em;
            color: var(--text-secondary);
        }

        /* Modal Styles */
        .modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.6);
            backdrop-filter: blur(8px);
            z-index: 2000;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 1rem;
        }
        .modal-content {
            background: var(--panel-bg);
            backdrop-filter: blur(30px);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-xl);
            max-width: 450px;
            width: 100%;
            box-shadow: var(--shadow-lg);
        }
        /* Print/PDF Export Styles */
        @media print {
            body { 
                background: var(--bg-color, #0a0a0a) !important; 
                color: #e5e7eb !important;
                margin: 0; padding: 0; 
                -webkit-print-color-adjust: exact !important;
                print-color-adjust: exact !important;
            }
            .print-hidden, .w-full.mb-8, #global-client-info, .control-bar {
                display: none !important;
            }
            #view-export {
                display: block !important;
                background: var(--bg-color, #0a0a0a) !important;
                box-shadow: none !important;
                padding: 0 !important;
                margin: 0 !important;
                max-width: none !important;
            }
            #view-export * {
                color: inherit;
            }
            #view-export .print-brand-text { color: var(--accent) !important; }
            #view-export .print-brand-bg { background-color: var(--accent) !important; color: black !important; }
            #view-export .print-subtext { color: #9ca3af !important; } /* neutral-400 */
            #view-export .print-border { border-color: rgba(255,255,255,0.1) !important; }
            #view-export .print-glass { background-color: rgba(255,255,255,0.05) !important; border: 1px solid rgba(255,255,255,0.1) !important; }
            #view-export .print-text-black { color: #ffffff !important; }
            #view-export .print-blue-text { color: #60a5fa !important; }
            #view-export .print-green-text { color: #4ade80 !important; }
            #view-export .print-red-text { color: #f87171 !important; }
            #view-export .print-yellow-text { color: #eab308 !important; }
            #view-export .print-orange-text { color: #fb923c !important; }
            #view-export .print-blue-bg { background-color: #60a5fa !important; }
            #view-export .print-green-bg { background-color: #4ade80 !important; }
            #view-export .print-red-bg { background-color: #f87171 !important; }
            #view-export .print-yellow-bg { background-color: #eab308 !important; }
            #view-export .print-orange-bg { background-color: #fb923c !important; }
            #view-export .print-neutral-bg { background-color: #4b5563 !important; }
        }
        
        /* ===== NUTRITION CALCULATOR TYPOGRAPHY (#view-nutrition + live KPI strip) ===== */
        #view-nutrition .text-neutral-500,
        #view-nutrition .text-neutral-400,
        .nut-kpi-dashboard .text-neutral-500,
        .nut-kpi-dashboard .text-neutral-400 {
            color: var(--text-secondary);
        }

        /* ---------- KPI dashboard shell ---------- */
        .nut-kpi-dashboard {
            position: relative;
            padding: 1.25rem;
            border-radius: var(--radius-2xl, 1.25rem);
            background:
                radial-gradient(120% 80% at 100% 0%, rgba(var(--accent-rgb, 56, 189, 248), 0.08) 0%, transparent 60%),
                linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.35) 100%),
                rgba(10, 10, 12, 0.65);
            border: 1px solid rgba(255, 255, 255, 0.08);
            backdrop-filter: blur(14px);
            -webkit-backdrop-filter: blur(14px);
            box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
        }
        @media (min-width: 768px) {
            .nut-kpi-dashboard { padding: 1.5rem 1.75rem; }
        }

        /* ---------- Header ---------- */
        .nut-kpi-dashboard .nut-kpi-header {
            margin-bottom: 1.25rem;
        }
        .nut-kpi-dashboard .nut-kpi-header__text { min-width: 0; }
        .nut-kpi-dashboard .nut-kpi-title {
            font-size: var(--text-subheading);
            font-weight: var(--fw-bold);
            line-height: var(--lh-tight);
            color: var(--text-primary);
            margin: 0;
        }
        .nut-kpi-dashboard .nut-kpi-subtitle {
            font-size: var(--text-caption);
            font-weight: var(--fw-normal);
            line-height: var(--lh-snug);
            color: var(--text-muted);
            margin: 0.2rem 0 0;
        }
        /* ---------- HERO ROW (calories + macros) ---------- */
        .nut-kpi-dashboard .nut-kpi-hero {
            display: grid;
            grid-template-columns: 1fr;
            gap: 0.75rem;
            margin-bottom: 1.5rem;
        }
        @media (min-width: 768px) {
            .nut-kpi-dashboard .nut-kpi-hero {
                grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
                gap: 1rem;
            }
        }
        .nut-kpi-dashboard .nut-kpi-hero-card {
            position: relative;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
            padding: 1.1rem 1.25rem;
            border-radius: var(--radius-xl, 1rem);
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.4) 100%);
            border: 1px solid rgba(255, 255, 255, 0.08);
            min-height: 7rem;
            overflow: hidden;
        }
        .nut-kpi-dashboard .nut-kpi-hero-card--cals {
            border-color: rgba(var(--accent-rgb, 56, 189, 248), 0.45);
            background:
                radial-gradient(160% 100% at 100% 0%, rgba(var(--accent-rgb, 56, 189, 248), 0.18) 0%, transparent 65%),
                linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.45) 100%);
        }
        .nut-kpi-dashboard .nut-kpi-hero-card--cals::before {
            content: "";
            position: absolute;
            inset-inline-start: 0;
            top: 1.1rem;
            bottom: 1.1rem;
            width: 3px;
            border-radius: 2px;
            background: rgb(var(--accent-rgb, 56, 189, 248));
        }
        .nut-kpi-dashboard .nut-kpi-hero-card__label {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            line-height: var(--lh-snug);
            color: var(--text-muted);
            letter-spacing: 0.05em;
            text-transform: uppercase;
        }
        html[lang="he"] .nut-kpi-dashboard .nut-kpi-hero-card__label,
        html[lang="he"] .nut-kpi-dashboard .nut-kpi-section__title {
            text-transform: none;
            letter-spacing: normal;
        }
        .nut-kpi-dashboard .nut-kpi-hero-card__value {
            display: flex;
            align-items: baseline;
            gap: 0.45rem;
            flex-wrap: wrap;
        }
        .nut-kpi-dashboard .nut-kpi-hero-card__number {
            font-size: var(--text-display);
            font-weight: var(--fw-bold);
            line-height: 1;
            color: var(--text-primary);
            letter-spacing: -0.01em;
        }
        .nut-kpi-dashboard .nut-kpi-hero-card--cals .nut-kpi-hero-card__number {
            color: rgb(var(--accent-rgb, 56, 189, 248));
        }
        .nut-kpi-dashboard .nut-kpi-hero-card__unit {
            font-size: var(--text-ui);
            font-weight: var(--fw-medium);
            color: var(--text-muted);
        }
        .nut-kpi-dashboard .nut-kpi-hero-card__body {
            display: flex;
            flex-direction: column;
            gap: 0.65rem;
            flex: 1;
            min-width: 0;
        }
        .nut-kpi-dashboard .nut-kpi-cals-note {
            display: block;
            font-size: var(--text-caption);
            font-weight: var(--fw-normal);
            color: var(--text-muted);
        }

        /* ---------- Macros (inside hero card) ---------- */
        .nut-kpi-dashboard .nut-kpi-macros {
            display: flex;
            flex-direction: column;
            gap: 0.65rem;
            width: 100%;
        }
        .nut-kpi-dashboard .nut-kpi-macros__row {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 0.5rem;
        }
        .nut-kpi-dashboard .nut-kpi-macros__item {
            display: inline-flex;
            align-items: baseline;
            gap: 0.35rem;
            font-size: var(--text-ui);
            font-weight: var(--fw-medium);
            line-height: var(--lh-snug);
            color: var(--text-secondary);
        }
        .nut-kpi-dashboard .nut-kpi-macros__dot {
            width: 0.5rem;
            height: 0.5rem;
            border-radius: 999px;
            flex-shrink: 0;
            align-self: center;
        }
        .nut-kpi-dashboard .nut-kpi-macros__name {
            font-weight: var(--fw-semibold);
            color: var(--text-muted);
            font-size: var(--text-caption);
            letter-spacing: 0.04em;
        }
        .nut-kpi-dashboard .nut-kpi-macros__num {
            font-size: var(--text-subheading);
            font-weight: var(--fw-bold);
            color: var(--text-primary);
            line-height: 1;
        }
        .nut-kpi-dashboard .nut-kpi-macros__suffix {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            color: var(--text-muted);
        }
        .nut-kpi-dashboard .nut-kpi-macros__item--p .nut-kpi-macros__dot,
        .nut-kpi-dashboard .nut-kpi-macros__seg--p { background: rgb(96 165 250); }
        .nut-kpi-dashboard .nut-kpi-macros__item--c .nut-kpi-macros__dot,
        .nut-kpi-dashboard .nut-kpi-macros__seg--c { background: rgb(74 222 128); }
        .nut-kpi-dashboard .nut-kpi-macros__item--f .nut-kpi-macros__dot,
        .nut-kpi-dashboard .nut-kpi-macros__seg--f { background: rgb(248 113 113); }
        .nut-kpi-dashboard .nut-kpi-macros__bar {
            display: flex;
            width: 100%;
            height: 0.45rem;
            border-radius: 999px;
            overflow: hidden;
            background: rgba(255, 255, 255, 0.08);
        }
        .nut-kpi-dashboard .nut-kpi-macros__seg {
            display: block;
            height: 100%;
            min-width: 0;
            transition: flex-basis 0.25s ease;
        }
        .nut-kpi-dashboard .nut-kpi-macros__seg--p { flex: 1 1 33%; }
        .nut-kpi-dashboard .nut-kpi-macros__seg--c { flex: 1 1 33%; }
        .nut-kpi-dashboard .nut-kpi-macros__seg--f { flex: 1 1 34%; }

        /* ---------- Sections (body comp, energy) ---------- */
        .nut-kpi-dashboard .nut-kpi-section + .nut-kpi-section {
            margin-top: 1.25rem;
        }
        .nut-kpi-dashboard .nut-kpi-section__header {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            margin-bottom: 0.75rem;
        }
        .nut-kpi-dashboard .nut-kpi-section__title {
            flex-shrink: 0;
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
            line-height: var(--lh-snug);
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            margin: 0;
            text-align: start;
        }
        .nut-kpi-dashboard .nut-kpi-section__line {
            flex: 1;
            height: 1px;
            background: linear-gradient(to left, transparent, rgba(255, 255, 255, 0.12));
        }
        html[dir="ltr"] .nut-kpi-dashboard .nut-kpi-section__line {
            background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.12));
        }

        /* ---------- Compact cards (body comp, energy) ---------- */
        .nut-kpi-dashboard .nut-kpi-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 0.65rem;
        }
        @media (min-width: 768px) {
            .nut-kpi-dashboard .nut-kpi-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
            .nut-kpi-dashboard .nut-kpi-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
            .nut-kpi-dashboard .nut-kpi-grid { gap: 0.85rem; }
        }
        .nut-kpi-dashboard .nut-kpi-card {
            display: flex;
            flex-direction: column;
            gap: 0.45rem;
            padding: 0.85rem 1rem;
            border-radius: var(--radius-lg, 0.875rem);
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.06);
            text-align: start;
            transition: border-color 0.15s ease, background 0.15s ease;
        }
        .nut-kpi-dashboard .nut-kpi-card:hover {
            border-color: rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.05);
        }
        .nut-kpi-dashboard .nut-kpi-card__label {
            display: block;
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            line-height: var(--lh-snug);
            color: var(--text-muted);
        }
        .nut-kpi-dashboard .nut-kpi-card__value {
            display: block;
            font-size: var(--text-heading);
            font-weight: var(--fw-bold);
            line-height: var(--lh-tight);
            color: var(--text-primary);
            min-height: 1.35em;
        }
        .nut-kpi-dashboard .nut-kpi-card__value.ltr-value,
        .nut-kpi-dashboard .nut-kpi-hero-card__number.ltr-value {
            direction: ltr;
            unicode-bidi: isolate;
            text-align: start;
        }
        html[dir="rtl"] .nut-kpi-dashboard .nut-kpi-card__value.ltr-value {
            text-align: end;
        }
        .nut-kpi-dashboard .nut-kpi-card__value--pending {
            font-size: var(--text-ui);
            font-weight: var(--fw-medium);
            font-style: italic;
            color: var(--text-muted);
            text-align: start;
        }
        #view-nutrition .nut-card-title {
            font-size: var(--text-subheading);
            font-weight: var(--fw-semibold);
            line-height: var(--lh-snug);
            color: var(--text-primary);
        }
        #view-nutrition .nut-hint {
            font-size: var(--text-caption);
            font-weight: var(--fw-medium);
            line-height: var(--lh-snug);
        }
        #view-nutrition .nut-hint--info {
            color: rgb(96 165 250 / 0.85);
        }
        #view-nutrition .nut-hint--success {
            color: rgb(74 222 128 / 0.85);
        }
        #view-nutrition .nut-macro-summary {
            font-size: var(--text-ui);
            font-weight: var(--fw-semibold);
        }
        #view-nutrition .nut-meal-value {
            font-size: var(--text-subheading);
            font-weight: var(--fw-semibold);
            color: var(--text-primary);
        }
        #view-nutrition .nut-meal-split {
            font-size: var(--text-small);
            font-weight: var(--fw-normal);
            color: var(--text-secondary);
        }
        #view-nutrition .nut-wa-preview {
            font-size: var(--text-ui);
            font-weight: var(--fw-normal);
            line-height: var(--lh-relaxed);
            color: var(--text-secondary);
            font-family: 'Ploni', sans-serif;
        }
        #view-nutrition #nut-math-breakdown {
            font-size: var(--text-ui);
            font-weight: var(--fw-normal);
            line-height: var(--lh-relaxed);
            color: var(--text-secondary);
        }
        #view-nutrition .nut-stall-btn {
            font-size: var(--text-caption);
            font-weight: var(--fw-semibold);
        }
        #view-nutrition .nut-proj-label {
            font-size: var(--text-small);
            font-weight: var(--fw-medium);
            color: rgba(var(--accent-rgb), 0.9);
        }

        /* ===== NUTRITION SLIDER ROW (label + KPI value) ===== */
        /* Two-column row: label fills available width, KPI sits right-aligned (LTR) /
           left-aligned (RTL — direction is inherited from <html dir>). No wasted third column. */
        #view-nutrition .nut-slider-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            flex-wrap: wrap;
        }
        #view-nutrition .nut-slider-label {
            flex: 1 1 12rem;
            min-width: 0;
            text-align: start;
            line-height: var(--lh-snug);
        }
        #view-nutrition .nut-slider-val {
            flex: 0 0 auto;
            text-align: end;
            white-space: nowrap;
        }
        /* When a card is contextually disabled (e.g. stall buttons outside fat-loss mode). */
        #view-nutrition #nut-stall-wrap.is-disabled .nut-stall-btn {
            opacity: 0.45;
            cursor: not-allowed;
        }
        #view-nutrition #nut-stall-wrap.is-disabled .nut-stall-btn:hover {
            transform: none;
        }
        /* Slider sizing — make touch targets big enough on phones. */
        #view-nutrition input[type="range"] {
            min-height: 32px;
        }
        @media (max-width: 480px) {
            #view-nutrition .goal-btn {
                padding: 0.85rem 0.5rem !important;
                font-size: var(--text-small) !important;
            }
        }

        /* ===== NUTRITION GOAL BUTTONS STYLING & MICRO-ANIMATIONS ===== */
        .goal-btn {
            padding: 1.1rem 1rem !important; /* Larger padding for premium feel */
            font-size: var(--text-ui) !important;
            font-weight: var(--fw-semibold) !important;
            border-radius: var(--radius-xl) !important;
            border: 1px solid rgba(255, 255, 255, 0.08) !important;
            background: rgba(255, 255, 255, 0.03) !important;
            color: var(--text-muted) !important;
            transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), var(--shadow-sm) !important;
            position: relative;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            cursor: pointer;
        }
        
        .goal-btn:hover {
            transform: translateY(-2px);
            border-color: rgba(var(--accent-rgb), 0.3) !important;
            background: rgba(255, 255, 255, 0.07) !important;
            color: #ffffff !important;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), var(--shadow-lg), var(--shadow-glow) !important;
        }
        
        .goal-btn:active {
            transform: translateY(0) scale(0.98);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
        }
        
        /* Active / Selected Goal state: subtle premium white theme, not locked to yellow */
        .goal-btn.active {
            border-color: rgba(255, 255, 255, 0.3) !important;
            background: rgba(255, 255, 255, 0.08) !important;
            color: #ffffff !important;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), var(--shadow-sm) !important;
            font-weight: var(--fw-bold) !important;
        }
        
        .goal-btn.active:hover {
            transform: translateY(-2px);
            border-color: rgba(var(--accent-rgb), 0.3) !important;
            background: rgba(255, 255, 255, 0.1) !important;
            color: #ffffff !important;
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), var(--shadow-lg), var(--shadow-glow) !important;
        }

/* Muscle library drawer — top-level (EN/LTR fix; do not use Tailwind right-0) */
#library-sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    width: 20rem !important;
    max-width: 90vw;
    height: 100% !important;
    z-index: 2001 !important;
    display: flex !important;
    flex-direction: column !important;
    background: rgb(23, 23, 23) !important;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    transform: translateX(100%) !important;
    pointer-events: none;
}
#library-sidebar.is-open {
    transform: translateX(0) !important;
    pointer-events: auto;
}

/* Nutrition Sex Dropdown Size Override */
#sex-select-container .selected-text {
    font-size: var(--text-emphasis) !important;
    font-weight: 500 !important;
}