@layer fonts, base, components, utilities, overrides;
@layer base {
/* ============================================
   Material 3 Expressive — 训练助手
   CSS snapshot for rollback / current-branch parity
   ============================================ */

@property --plan-progress { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@property --pro-stop      { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@property --carb-stop     { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@property --fat-stop      { syntax: '<angle>'; inherits: true; initial-value: 0deg; }

/* --- Design Tokens --- */
:root {
    /* Primary — Default Blue */
    --md-sys-primary: #0061a4;
    --md-sys-on-primary: #ffffff;
    --md-sys-primary-container: #d1e4ff;
    --md-sys-on-primary-container: #001d36;

    /* Secondary */
    --md-sys-secondary: #535f70;
    --md-sys-on-secondary: #ffffff;
    --md-sys-secondary-container: #d7e3f8;
    --md-sys-on-secondary-container: #101c2b;

    /* Tertiary — Warm Accent */
    --md-sys-tertiary: #6b5778;
    --md-sys-on-tertiary: #ffffff;
    --md-sys-tertiary-container: #f2daff;
    --md-sys-on-tertiary-container: #251431;

    /* Session Timer Accent — Amber */
    --md-sys-amber: #f59e0b;
    --md-sys-amber-container: #fef3c7;
    --md-sys-on-amber-container: #78350f;

    /* Surface */
    --md-sys-surface: #fdfcff;
    --md-sys-surface-dim: #d9d9e0;
    --md-sys-surface-container-lowest: #ffffff;
    --md-sys-surface-container-low: #f4f3fa;
    --md-sys-surface-container: #eeedf4;
    --md-sys-surface-container-high: #e8e7ef;
    --md-sys-surface-container-highest: #e2e2e9;
    --md-sys-surface-tint: var(--md-sys-primary);
    --md-sys-on-surface: #1a1c1e;
    --md-sys-on-surface-variant: #43474e;
    --md-sys-inverse-surface: #30322e;
    --md-sys-inverse-on-surface: #f1f1ea;

    /* Outline */
    --md-sys-outline: #73777f;
    --md-sys-outline-variant: #c3c7cf;
    --timer-gradient-start: #001d36;
    --timer-gradient-mid: #0061a4;
    --timer-gradient-end: #2f7cbd;
    --timer-time-color: #d1e4ff;
    --timer-orb: rgba(209, 228, 255, 0.15);
    --theme-seed: #0061a4;

    /* Error */
    --md-sys-error: #ba1a1a;
    --md-sys-error-container: #ffdad6;
    --md-sys-on-error-container: #410002;

    /* Elevation */
    --md-sys-elevation-1: 0 1px 2px rgba(0,0,0,0.1), 0 1px 3px 1px rgba(0,0,0,0.06);
    --md-sys-elevation-2: 0 1px 2px rgba(0,0,0,0.1), 0 2px 6px 2px rgba(0,0,0,0.08);
    --md-sys-elevation-3: 0 4px 8px 3px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.1);

    /* Shape */
    --md-sys-shape-xs: 4px;
    --md-sys-shape-sm: 8px;
    --md-sys-shape-md: 12px;
    --md-sys-shape-lg: 16px;
    --md-sys-shape-xl: 28px;
    --md-sys-shape-full: 9999px;

    /* Typescale */
    --md-sys-typescale-display-large-size: 57px;
    --md-sys-typescale-display-large-line-height: 64px;
    --md-sys-typescale-display-large-weight: 400;
    --md-sys-typescale-display-large-letter-spacing: 0;
    --md-sys-typescale-display-medium-size: 45px;
    --md-sys-typescale-display-medium-line-height: 52px;
    --md-sys-typescale-display-medium-weight: 400;
    --md-sys-typescale-display-medium-letter-spacing: 0;
    --md-sys-typescale-display-small-size: 36px;
    --md-sys-typescale-display-small-line-height: 44px;
    --md-sys-typescale-display-small-weight: 400;
    --md-sys-typescale-display-small-letter-spacing: 0;
    --md-sys-typescale-headline-large-size: 32px;
    --md-sys-typescale-headline-large-line-height: 40px;
    --md-sys-typescale-headline-large-weight: 400;
    --md-sys-typescale-headline-large-letter-spacing: 0;
    --md-sys-typescale-headline-medium-size: 28px;
    --md-sys-typescale-headline-medium-line-height: 36px;
    --md-sys-typescale-headline-medium-weight: 400;
    --md-sys-typescale-headline-medium-letter-spacing: 0;
    --md-sys-typescale-headline-small-size: 24px;
    --md-sys-typescale-headline-small-line-height: 32px;
    --md-sys-typescale-headline-small-weight: 400;
    --md-sys-typescale-headline-small-letter-spacing: 0;
    --md-sys-typescale-title-large-size: 22px;
    --md-sys-typescale-title-large-line-height: 28px;
    --md-sys-typescale-title-large-weight: 400;
    --md-sys-typescale-title-large-letter-spacing: 0;
    --md-sys-typescale-title-medium-size: 16px;
    --md-sys-typescale-title-medium-line-height: 24px;
    --md-sys-typescale-title-medium-weight: 500;
    --md-sys-typescale-title-medium-letter-spacing: 0;
    --md-sys-typescale-title-small-size: 14px;
    --md-sys-typescale-title-small-line-height: 20px;
    --md-sys-typescale-title-small-weight: 500;
    --md-sys-typescale-title-small-letter-spacing: 0;
    --md-sys-typescale-body-large-size: 16px;
    --md-sys-typescale-body-large-line-height: 24px;
    --md-sys-typescale-body-large-weight: 400;
    --md-sys-typescale-body-large-letter-spacing: 0;
    --md-sys-typescale-body-medium-size: 14px;
    --md-sys-typescale-body-medium-line-height: 20px;
    --md-sys-typescale-body-medium-weight: 400;
    --md-sys-typescale-body-medium-letter-spacing: 0;
    --md-sys-typescale-body-small-size: 12px;
    --md-sys-typescale-body-small-line-height: 16px;
    --md-sys-typescale-body-small-weight: 400;
    --md-sys-typescale-body-small-letter-spacing: 0;
    --md-sys-typescale-label-large-size: 14px;
    --md-sys-typescale-label-large-line-height: 20px;
    --md-sys-typescale-label-large-weight: 500;
    --md-sys-typescale-label-large-letter-spacing: 0;
    --md-sys-typescale-label-medium-size: 12px;
    --md-sys-typescale-label-medium-line-height: 16px;
    --md-sys-typescale-label-medium-weight: 500;
    --md-sys-typescale-label-medium-letter-spacing: 0;
    --md-sys-typescale-label-small-size: 11px;
    --md-sys-typescale-label-small-line-height: 16px;
    --md-sys-typescale-label-small-weight: 500;
    --md-sys-typescale-label-small-letter-spacing: 0;

    /* Motion */
    --md-sys-motion-standard: cubic-bezier(0.2, 0, 0, 1);
    --md-sys-motion-standard-decelerate: cubic-bezier(0, 0, 0, 1);
    --md-sys-motion-standard-accelerate: cubic-bezier(0.3, 0, 1, 1);
    --md-sys-motion-emphasized: cubic-bezier(0.2, 0, 0, 1);
    --md-sys-motion-emphasized-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1);
    --md-sys-motion-emphasized-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
    --md-sys-motion-duration-short: 200ms;
    --md-sys-motion-duration-medium: 400ms;
    --md-sys-motion-duration-long: 500ms;
    --md-sys-motion-duration-short1: 50ms;
    --md-sys-motion-duration-short2: 100ms;
    --md-sys-motion-duration-short3: 150ms;
    --md-sys-motion-duration-short4: 200ms;
    --md-sys-motion-duration-medium1: 250ms;
    --md-sys-motion-duration-medium2: 300ms;
    --md-sys-motion-duration-medium3: 350ms;
    --md-sys-motion-duration-medium4: 400ms;
    --md-sys-motion-duration-long1: 450ms;
    --md-sys-motion-duration-long2: 500ms;
    --md-sys-motion-duration-long3: 550ms;
    --md-sys-motion-duration-long4: 600ms;
    --md-sys-motion-duration-extra-long1: 700ms;
    --md-sys-motion-duration-extra-long2: 800ms;
    --md-sys-motion-duration-extra-long3: 900ms;
    --md-sys-motion-duration-extra-long4: 1000ms;
    --md-state-hover: 0.08;
    --md-state-press: 0.14;
    --md-expressive-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --md-sys-motion-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Glass Tokens */
    --glass-bg: color-mix(in srgb, var(--md-sys-surface-container-lowest) 58%, transparent);
    --glass-bg-strong: color-mix(in srgb, var(--md-sys-surface-container-lowest) 72%, transparent);
    --glass-border: color-mix(in srgb, var(--md-sys-surface-container-lowest) 64%, transparent);
    --glass-shadow-inset: inset 0 1px 0 color-mix(in srgb, var(--md-sys-surface-container-lowest) 70%, transparent);
    --glass-shadow-out: 0 2px 10px color-mix(in srgb, var(--md-sys-on-surface) 6%, transparent);

    /* Glass Layered Blur */
    --glass-blur-sm: blur(12px) saturate(150%);
    --glass-blur-md: blur(20px) saturate(160%);
    --glass-blur-lg: blur(28px) saturate(180%);

    /* Liquid Glass edge */
    --glass-edge: linear-gradient(135deg,
        color-mix(in srgb, var(--md-sys-surface-container-lowest) 80%, transparent) 0%,
        color-mix(in srgb, var(--md-sys-surface-container-lowest) 30%, transparent) 50%,
        color-mix(in srgb, var(--md-sys-surface-container-lowest) 70%, transparent) 100%);

    --glass-blur: var(--glass-blur-md);

    /* Macro Colors — must match record/diet tabs (17-record-tabs-health.css) */
    --c-pro: #0061a4;   /* 蛋白质 protein → 蓝 */
    --c-carb: #8b5cf6;  /* 碳水 carb → 紫 */
    --c-fat: #f59e0b;   /* 脂肪 fat → 黄 */
}


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

body {
    background: #dde1ea;
    transition: background 0.8s var(--md-sys-motion-emphasized);
    /* 字体回退链：优先使用各平台自带的高质量系统字体，避免硬塞未托管的 Roboto。
       Android：Roboto / Noto Sans CJK SC（AOSP/Pixel）→ MiSans VF（小米/红米 HyperOS）
                → OPPO Sans（OPPO/OnePlus/realme）→ HarmonyOS Sans SC（华为/荣耀，含 OPPO 部分机型回退）
                → Source Han Sans SC（部分定制 ROM 自带思源黑体子集）。
       iOS / macOS：-apple-system / BlinkMacSystemFont → PingFang SC。
       Windows：Segoe UI Variable / Segoe UI → Microsoft YaHei UI。 */
    font-family:
        -apple-system, BlinkMacSystemFont,
        "Segoe UI Variable Text", "Segoe UI",
        Roboto, "Noto Sans CJK SC", "Noto Sans SC",
        "MiSans VF", "MiSans", "OPPO Sans", "HarmonyOS Sans SC",
        "Source Han Sans SC", "Source Han Sans CN",
        "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei UI", "Microsoft YaHei",
        system-ui, sans-serif;
    color: var(--md-sys-on-surface);
    min-height: 100vh;
    padding: 0;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
    font-feature-settings: "kern", "ss01";
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    min-height: 100%;
}

/* 训练助手 UI 中数字密集（卡路里/秒数/组数/重量）。统一启用 tabular figures，
   让数字等宽对齐，主流系统字体（PingFang、Segoe UI、HarmonyOS Sans、MiSans、Roboto）都支持。 */
.num,
.val,
.unit,
input[type="number"],
input[type="date"],
input[type="time"],
.timer,
[class*="ring-"] .num,
[class*="-num"],
[class*="-value"],
[class*="-count"] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum", "cv11";
}


}
@layer components {
.app-update-banner {
    position: sticky;
    top: 0;
    z-index: 300;
    margin: 10px 16px 0;
    padding: 12px 14px;
    border-radius: 18px;
    background: color-mix(in srgb, var(--md-sys-primary-container) 82%, white);
    color: var(--md-sys-on-primary-container);
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 10px;
    box-shadow: var(--md-sys-elevation-2);
}
.app-update-banner strong { display: block; font-size: 13px; }
.app-update-banner small { display: block; font-size: 11px; opacity: 0.85; }
.app-update-banner .material-symbols-rounded { color: var(--md-sys-primary); }

}
@layer components {
/* --- Top App Bar --- */
.md-top-app-bar {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    background: transparent;
    position: static;
    flex: none;
    transition: background .3s var(--md-sys-motion-emphasized),
                box-shadow .3s var(--md-sys-motion-emphasized);
}
.workout-only-bar { margin-bottom: 0; }
.bar-leading {
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-icon {
    font-size: 20px;
    color: var(--md-sys-primary);
    font-variation-settings: 'FILL' 1, 'wght' 600;
}
.app-title {
    font-size: 22px;
    font-weight: 500;
    color: var(--md-sys-on-surface);
    letter-spacing: -0.3px;
}
.bar-trailing {
    display: flex;
    align-items: center;
    gap: 6px;
}


}
@layer components {
/* --- Chip --- */
.md-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container-high);
    color: var(--md-sys-on-surface-variant);
    letter-spacing: 0.3px;
    line-height: 1;
    white-space: nowrap;
}


}
@layer components {
/* --- App Shell / Page --- */
.app-shell-v6 {
    width: min(100vw, 412px);
    height: 100dvh;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--md-sys-primary-container) 65%, transparent) 0%, transparent 38%),
        radial-gradient(circle at 100% 22%, color-mix(in srgb, var(--md-sys-tertiary-container) 55%, transparent) 0%, transparent 42%),
        radial-gradient(circle at 50% 100%, color-mix(in srgb, var(--md-sys-secondary-container) 45%, transparent) 0%, transparent 50%),
        var(--md-sys-surface);
    transition: background 0.8s var(--md-sys-motion-emphasized);
}

#app {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: grid;
}

.page {
    min-height: 0;
    min-width: 0;
    height: 100%;
    padding: 0 14px 14px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-width: none;
    display: none;
}

.page::-webkit-scrollbar { display: none; }
.page.active { display: block; animation: fadeSlideIn var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized-decelerate); }

#ai-coach.page.active,
#profile.page.active {
    display: block;
}

#workout { padding-bottom: 14px; }

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

@media (min-width: 600px) {
    body {
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 24px;
    }

    .app-shell-v6 {
        width: 412px;
        height: 760px;
        border: 10px solid #1d212b;
        border-radius: 40px;
        box-shadow: 0 30px 70px rgba(20,30,60,0.22), 0 6px 16px rgba(20,30,60,0.08);
    }
}


}
@layer components {
/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 8px;
}
.page-header .material-symbols-rounded {
    font-size: 24px;
    color: var(--md-sys-primary);
    font-variation-settings: 'FILL' 1;
}
.page-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--md-sys-on-surface);
}

}
@layer components {
/* --- Cards --- */
.md-card {
    background: var(--md-sys-surface-container-low);
    margin: 8px 16px;
    padding: 16px;
    border-radius: var(--md-sys-shape-lg);
    border: 1px solid var(--md-sys-outline-variant);
    transition:
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        transform var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.md-card:active {
    transform: scale(0.996);
}
.md-card:hover {
    background-image:
        linear-gradient(0deg, color-mix(in srgb, var(--md-sys-surface-tint) 8%, transparent), color-mix(in srgb, var(--md-sys-surface-tint) 8%, transparent));
}

/* AI 卡片搜索命中高亮 */
.ai-card mark.ai-hit,
.advice-card mark.ai-hit,
mark.ai-hit {
    background: var(--md-sys-color-tertiary-container, #ffe08a);
    color: var(--md-sys-color-on-tertiary-container, #2a1a00);
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 600;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

@media (prefers-color-scheme: dark) {
    mark.ai-hit {
        background: var(--md-sys-color-tertiary, #ffb866);
        color: #1a1200;
    }
}


}
@layer components {
/* --- Timer Panel (Expressive) --- */
.timer-panel {
    background: linear-gradient(145deg, var(--timer-gradient-start), var(--timer-gradient-mid) 42%, var(--timer-gradient-end) 100%);
    color: white;
    text-align: center;
    position: relative;
    padding: 32px 16px 18px;
    border: none;
    overflow: hidden;
}
.timer-panel:hover,
.timer-panel:active {
    background: linear-gradient(145deg, var(--timer-gradient-start), var(--timer-gradient-mid) 42%, var(--timer-gradient-end) 100%);
}
.timer-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 0%, rgba(255,255,255,0.12) 46%, transparent 78%);
    opacity: 0.62;
    pointer-events: none;
    z-index: 0;
}
.timer-panel::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, var(--timer-orb) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}
.timer-panel > * {
    position: relative;
    z-index: 1;
}
.timer-tts-btn {
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 2;
    min-width: 42px;
    height: 24px;
    border: 1px solid color-mix(in srgb, var(--md-sys-primary-container) 42%, transparent);
    border-radius: 8px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    place-items: center;
    justify-content: center;
    color: var(--md-sys-on-primary-container);
    background: color-mix(in srgb, var(--md-sys-primary-container) 86%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--md-sys-on-primary) 18%, transparent), 0 4px 12px color-mix(in srgb, var(--timer-gradient-start) 28%, transparent);
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        color var(--md-sys-motion-duration-short),
        background var(--md-sys-motion-duration-short),
        border-color var(--md-sys-motion-duration-short);
}
.timer-tts-btn:active { transform: scale(0.96); }
.timer-wakelock-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: transparent;
    color: rgba(255,255,255,0.62);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.timer-wakelock-btn .material-symbols-rounded {
    font-size: 12px;
    line-height: 1;
}
.timer-wakelock-btn.is-active {
    color: rgba(255,255,255,0.72);
    pointer-events: none;
}
.timer-wakelock-btn:active {
    background: rgba(255,255,255,0.12);
}
.timer-tts-btn[data-mode="online-first"] {
    color: var(--md-sys-on-primary-container);
    background: color-mix(in srgb, var(--md-sys-primary-container) 88%, transparent);
    border-color: color-mix(in srgb, var(--md-sys-primary) 32%, transparent);
}
.timer-tts-btn[data-mode="local-first"] {
    color: var(--md-sys-on-secondary-container);
    background: color-mix(in srgb, var(--md-sys-secondary-container) 88%, transparent);
    border-color: color-mix(in srgb, var(--md-sys-secondary) 32%, transparent);
}
.timer-tts-btn[data-mode="online-only"] {
    color: var(--md-sys-on-tertiary-container);
    background: color-mix(in srgb, var(--md-sys-tertiary-container) 88%, transparent);
    border-color: color-mix(in srgb, var(--md-sys-tertiary) 32%, transparent);
}
.timer-tts-btn[data-mode="local-only"] {
    color: var(--md-sys-on-surface-variant);
    background: color-mix(in srgb, var(--md-sys-surface-container-highest) 82%, transparent);
    border-color: color-mix(in srgb, var(--md-sys-outline-variant) 70%, transparent);
}
#statusText {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--md-sys-primary-container);
    opacity: 0.9;
    text-transform: uppercase;
}
#mainTime {
    font-size: clamp(78px, 28vw, 128px);
    font-weight: 900;
    color: var(--timer-time-color);
    line-height: 1;
    margin: 8px 0;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 20px rgba(209, 228, 255, 0.32);
    letter-spacing: -2px;
}
#subText {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    min-height: 20px;
    font-weight: 500;
}
.timer-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(164,245,154,0.15);
}
.stat-item { text-align: center; }
.stat-label {
    display: block;
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.timer-stats b {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
}
/* Session time — warm amber accent */
.session-time {
    color: var(--md-sys-amber) !important;
    text-shadow: 0 0 12px rgba(245,158,11,0.35);
}

/* Timer Tweak ±15s chips — dark glass context inside timer-panel */
.timer-tweak {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1;
}
.timer-tweak .md-chip {
    font-size: 13px;
    font-weight: 700;
    padding: 6px 20px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.15s var(--md-sys-motion-spring),
                background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.timer-tweak .md-chip:hover {
    background: rgba(255, 255, 255, 0.18);
}
.timer-tweak .md-chip:active {
    transform: scale(0.94);
    background: rgba(255, 255, 255, 0.26);
}


}
@layer components {
/* --- Floating Label Input Fields --- */
.md-field {
    position: relative;
    margin-bottom: 4px;
}
.md-field input,
.md-field select {
    width: 100%;
    padding: 17px 12px 5px;
    border: 1.5px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-sm);
    background: var(--md-sys-surface-container-lowest);
    font-size: 16px;
    color: var(--md-sys-on-surface);
    outline: none;
    transition:
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    -webkit-appearance: none;
    appearance: none;
}
.md-field label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--md-sys-on-surface-variant);
    pointer-events: none;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    background: transparent;
    padding: 0 2px;
}
.md-field input:focus + label,
.md-field input:not(:placeholder-shown) + label,
.md-field select:focus + label,
.md-field select:valid + label {
    top: 5px;
    transform: translateY(0);
    font-size: 10px;
    color: var(--md-sys-primary);
    font-weight: 600;
}
.md-field input:focus,
.md-field select:focus {
    border-color: var(--md-sys-primary);
    border-width: 2px;
    padding: 16px 11px 4px;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-primary) 14%, transparent);
}
.md-field input::placeholder { color: transparent; }
.md-field select { cursor: pointer; padding-right: 32px; }

}
@layer components {
/* --- Grid --- */
.md-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 8px 0;
}
.span-full { grid-column: 1 / -1; }

}
@layer components {
/* --- Divider --- */
.md-divider {
    height: 1px;
    background: var(--md-sys-outline-variant);
    margin: 12px 0;
    opacity: 0.6;
}

}
@layer components {
/* --- Switch (M3 Expressive) --- */
.md-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--md-sys-on-surface);
}
.switch-track {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
    cursor: pointer;
}
.switch-track input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-thumb {
    position: absolute;
    inset: 0;
    background: var(--md-sys-surface-container-highest);
    border: 2px solid var(--md-sys-outline);
    border-radius: var(--md-sys-shape-full);
    transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
.switch-thumb::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--md-sys-outline);
    border-radius: 50%;
    transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
.switch-track input:checked + .switch-thumb {
    background: var(--md-sys-primary);
    border-color: var(--md-sys-primary);
}
.switch-track input:checked + .switch-thumb::before {
    left: 28px;
    width: 24px;
    height: 24px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--md-sys-on-primary);
}

}
@layer components {
/* --- Buttons --- */
.md-btn {
    border: none;
    border-radius: var(--md-sys-shape-full);
    height: 44px;
    min-width: 48px;
    padding: 0 24px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.2px;
    line-height: 1;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.md-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.md-btn:active::after { opacity: 0.12; }
.md-btn:hover::after { opacity: var(--md-state-hover); }
.md-btn:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    box-shadow: none;
}
.md-btn-filled {
    background: var(--md-sys-primary);
    color: var(--md-sys-on-primary);
    width: 100%;
    margin-top: 12px;
    box-shadow: var(--md-sys-elevation-1);
    font-size: 15px;
    height: 48px;
}
.md-btn-filled:hover { box-shadow: var(--md-sys-elevation-2); }
.md-btn:focus-visible,
.md-fab:focus-visible,
.nav-item:focus-visible,
.theme-swatch:focus-visible,
.color-picker:focus-within {
    outline: 3px solid color-mix(in srgb, var(--md-sys-primary) 45%, transparent);
    outline-offset: 3px;
}
.md-btn-tonal {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
    flex: 1;
    height: 44px;
}
.md-btn-tonal:hover { box-shadow: var(--md-sys-elevation-1); }

.md-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    overflow: hidden;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.md-icon-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.md-icon-btn:hover { color: var(--md-sys-on-surface); }
.md-icon-btn:hover::after { opacity: var(--md-state-hover, 0.08); }
.md-icon-btn:active { transform: scale(0.92); }
.md-icon-btn:active::after { opacity: var(--md-state-press, 0.12); }
.md-icon-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--md-sys-primary) 45%, transparent);
    outline-offset: 2px;
}
.md-icon-btn:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}
.md-icon-btn:disabled::after { display: none; }
.md-icon-btn .material-symbols-rounded {
    position: relative;
    z-index: 1;
    font-size: 22px;
}

.md-row { display: flex; gap: 8px; margin-top: 8px; }

@media (max-width: 420px) {
    .md-btn {
        padding-inline: 14px;
        font-size: 13px;
    }
}


}
@layer components {
/* --- List Items (Expressive) --- */
.list-item {
    background: var(--md-sys-surface-container-lowest);
    padding: 14px 16px;
    border-radius: var(--md-sys-shape-md);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--md-sys-outline-variant);
    margin: 6px 16px;
    font-size: 14px;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.list-item:active {
    background: var(--md-sys-surface-container);
    transform: scale(0.99);
}
.list-item strong {
    font-size: 15px;
    font-weight: 600;
    color: var(--md-sys-on-surface);
    display: block;
}
.list-item small {
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    line-height: 1.6;
}
.list-item .item-chip {
    display: inline-block;
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
    padding: 2px 8px;
    border-radius: var(--md-sys-shape-full);
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}
.record-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    font-size: 20px;
    font-variation-settings: 'FILL' 1;
    flex: none;
}
.sort-btns {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.sort-btn {
    border: none;
    background: none;
    padding: 2px;
    cursor: pointer;
    color: var(--md-sys-on-surface-variant);
    border-radius: var(--md-sys-shape-xs);
    transition: background var(--md-sys-motion-duration-short);
}
.sort-btn:active { background: var(--md-sys-surface-container-high); }
.delete-btn {
    border: none;
    background: none;
    color: var(--md-sys-error);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--md-sys-shape-sm);
    transition: background var(--md-sys-motion-duration-short);
    opacity: 0.7;
}
.delete-btn:active { opacity: 1; background: var(--md-sys-error-container); }
.save-lib-btn {
    border: none;
    background: none;
    color: var(--md-sys-primary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--md-sys-shape-sm);
    transition: background var(--md-sys-motion-duration-short);
    opacity: 0.7;
}
.save-lib-btn .material-symbols-rounded { font-size: 20px; }
.save-lib-btn:active { opacity: 1; background: var(--md-sys-primary-container); }

/* --- Collapsible month / weight history groups --- */
.history-month-group { display: grid; gap: 4px; margin-bottom: 6px; }
.history-month-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface);
    cursor: pointer;
    text-align: left;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.history-month-head::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.history-month-head:hover { box-shadow: var(--md-sys-elevation-1); }
.history-month-head:hover::after { opacity: var(--md-state-hover); }
.history-month-head:active { transform: scale(0.985); background: var(--md-sys-surface-container-high); }
.history-month-head:active::after { opacity: var(--md-state-press); }
.history-month-head .material-symbols-rounded { font-size: 18px; color: var(--md-sys-primary); position: relative; z-index: 1; }
.history-month-head strong { flex: 1; font-size: 13px; position: relative; z-index: 1; }
.history-month-head small { color: var(--md-sys-on-surface-variant); font-size: 11px; font-weight: 700; white-space: nowrap; position: relative; z-index: 1; }
.history-month-content { display: grid; gap: 4px; }
.history-month-group.collapsed .history-month-content { display: none; }

/* History older records group */
.history-older-group { margin-top: 6px; }
.history-older-head {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: var(--md-sys-shape-sm);
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface-variant);
    cursor: pointer;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.history-older-head::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.history-older-head:hover::after { opacity: var(--md-state-hover); }
.history-older-head:active { transform: scale(0.98); }
.history-older-head:active::after { opacity: var(--md-state-press); }
.history-older-head .material-symbols-rounded { font-size: 16px; position: relative; z-index: 1; }
.history-older-head small { position: relative; z-index: 1; }
.history-older-content { display: grid; gap: 4px; margin-top: 4px; }
.history-older-group.collapsed .history-older-content { display: none; }

.weight-history-card { display: grid; gap: 8px; }
.weight-history-head {
    width: 100%;
    border: none;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.weight-history-head::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.weight-history-head:hover { box-shadow: var(--md-sys-elevation-1); }
.weight-history-head:hover::after { opacity: var(--md-state-hover); }
.weight-history-head:active { transform: scale(0.985); background: var(--md-sys-surface-container-high); }
.weight-history-head:active::after { opacity: var(--md-state-press); }
.weight-history-head .material-symbols-rounded { position: relative; z-index: 1; font-size: 18px; color: var(--md-sys-primary); }
.weight-history-head strong { flex: 1; position: relative; z-index: 1; font-size: 13px; }
.weight-history-head small { position: relative; z-index: 1; color: var(--md-sys-on-surface-variant); font-size: 11px; font-weight: 700; white-space: nowrap; }
.weight-history-content { display: grid; gap: 6px; }
.weight-history-card.collapsed .weight-history-content { display: none; }

.action-phase-group { display: grid; gap: 6px; margin-bottom: 10px; }
.action-phase-head {
    font-size: 12px; font-weight: 800;
    color: var(--md-sys-on-surface-variant);
    padding: 4px 12px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    width: max-content;
}


/* TASK-22: List item swipe-open delete reveal (M3 Expressive) */
.list-item {
    transition: transform .28s var(--md-expressive-spring);
    touch-action: pan-y;
}
.list-item.swipe-open .delete-btn {
    background: var(--md-sys-error, #b3261e); color: #fff;
}
}
@layer components {
/* --- Record Calendar --- */
.record-section-title {
    margin: 14px 20px 6px;
    font-size: 14px;
    font-weight: 800;
    color: var(--md-sys-on-surface);
    letter-spacing: 0.2px;
}
.hero-card {
    overflow: hidden;
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--md-sys-primary-container) 65%, transparent) 0%, transparent 45%),
        linear-gradient(180deg, color-mix(in srgb, var(--md-sys-surface-container-lowest) 80%, transparent), var(--md-sys-surface-container-low));
    border-radius: 28px;
    border-width: 1px;
    box-shadow:
        0 12px 30px rgba(0, 29, 54, 0.08),
        inset 0 1px 0 rgba(255,255,255,0.28);
}
.hero-kicker {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: var(--md-sys-shape-full);
    background: color-mix(in srgb, var(--md-sys-primary-container) 60%, transparent);
    color: var(--md-sys-on-primary-container);
    font-size: 11px;
    font-weight: 800;
    margin-bottom: 10px;
}
.hero-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.hero-title-row h3 {
    font-size: 32px;
    line-height: 1.05;
    color: var(--md-sys-on-surface);
    letter-spacing: -0.4px;
}
.hero-title-row p {
    margin-top: 6px;
    color: var(--md-sys-on-surface-variant);
    font-size: 13px;
    line-height: 1.45;
}
.hero-icon {
    width: 58px;
    height: 58px;
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    font-size: 28px;
    font-variation-settings: 'FILL' 1;
    flex: none;
}
.today-focus-card { display: grid; gap: 16px; }
.today-focus-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.today-focus-text h3 {
    font-size: 28px;
    line-height: 1.08;
    color: var(--md-sys-on-surface);
    letter-spacing: -0.4px;
    margin-top: 2px;
}
.today-focus-text p {
    margin-top: 6px;
    color: var(--md-sys-on-surface-variant);
    font-size: 13px;
    line-height: 1.45;
}
.today-focus-ring {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(
        var(--md-sys-primary) calc(var(--progress) * 1%),
        var(--md-sys-surface-container-highest) 0
    );
    position: relative;
    flex: none;
}
.today-focus-ring.macro-focus-ring {
    background:
        conic-gradient(
            from -90deg,
            var(--c-pro) 0deg var(--pro-stop, 0deg),
            color-mix(in srgb, var(--c-pro) 18%, var(--md-sys-surface-container-highest)) var(--pro-stop, 0deg) 120deg,
            var(--c-carb) 120deg var(--carb-stop, 120deg),
            color-mix(in srgb, var(--c-carb) 18%, var(--md-sys-surface-container-highest)) var(--carb-stop, 120deg) 240deg,
            var(--c-fat) 240deg var(--fat-stop, 240deg),
            color-mix(in srgb, var(--c-fat) 20%, var(--md-sys-surface-container-highest)) var(--fat-stop, 240deg) 360deg
        );
}
.today-focus-ring::after {
    content: '';
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: var(--md-sys-surface-container-low);
}
.today-focus-ring > div {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
}
.today-focus-ring b {
    font-size: 20px;
    line-height: 1;
    color: var(--md-sys-primary);
}
.today-focus-ring small {
    margin-top: 2px;
    font-size: 10px;
    font-weight: 800;
    color: var(--md-sys-on-surface-variant);
}
.today-focus-ring em {
    margin-top: 1px;
    font-size: 9px;
    line-height: 1;
    font-style: normal;
    font-weight: 800;
    color: var(--md-sys-tertiary);
    white-space: nowrap;
}
.today-focus-energy {
    display: grid;
    gap: 2px;
}
.today-focus-energy strong {
    font-size: 26px;
    line-height: 1.05;
    color: var(--md-sys-on-surface);
}
.today-focus-energy span {
    font-size: 13px;
    font-weight: 700;
    color: var(--md-sys-primary);
}
.today-focus-hint {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-lg);
    background: color-mix(in srgb, var(--md-sys-tertiary-container) 35%, var(--md-sys-surface-container-lowest));
}
.today-focus-hint b {
    color: var(--md-sys-tertiary);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}
.today-focus-hint p {
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    line-height: 1.45;
}
.hero-stat-row {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.hero-stat {
    padding: 10px 8px;
    border-radius: var(--md-sys-shape-md);
    background: color-mix(in srgb, var(--md-sys-surface-container-lowest) 86%, transparent);
    display: grid;
    gap: 3px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 70%, transparent);
}
.hero-stat b { font-size: 20px; color: var(--md-sys-primary); }
.hero-stat small { color: var(--md-sys-on-surface-variant); font-size: 11px; }
.calendar-card {
    padding: 14px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.68), rgba(255,255,255,0.2)),
        var(--md-sys-surface-container-low);
    box-shadow: var(--md-sys-elevation-1);
}
.calendar-toolbar {
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.calendar-toolbar strong {
    text-align: center;
    font-size: 18px;
    font-weight: 900;
    color: var(--md-sys-on-surface);
}
.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.icon-btn:active { transform: scale(0.9); }
.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}
.calendar-weekdays {
    gap: 4px;
    margin-bottom: 6px;
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    font-weight: 800;
    text-align: center;
}
.calendar-grid { gap: 4px; }
.calendar-day {
    min-height: 62px;
    max-height: 62px;
    border-radius: 10px;
    padding: 5px 4px;
    background: var(--md-sys-surface-container-lowest);
    border: 1px solid transparent;
    overflow: hidden;
}
.calendar-day.empty {
    background: transparent;
}
.calendar-day.has-record {
    border-color: color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
    background: color-mix(in srgb, var(--md-sys-primary-container) 30%, var(--md-sys-surface-container-lowest));
}
.calendar-day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 14px;
    max-height: 14px;
    gap: 2px;
    font-size: 11px;
    font-weight: 800;
    color: var(--md-sys-on-surface);
}
.calendar-day-head b {
    font-size: 9px;
    color: var(--md-sys-primary);
    white-space: nowrap;
}
.calendar-events {
    display: grid;
    gap: 2px;
    margin-top: 3px;
    overflow: hidden;
}
.calendar-event {
    min-width: 0;
    padding: 0 2px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--event-color) 18%, white);
    color: color-mix(in srgb, var(--event-color) 65%, var(--md-sys-on-surface));
    font-size: 9px;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 2px solid var(--event-color);
    display: flex;
    align-items: center;
    gap: 2px;
}
.calendar-event .material-symbols-rounded {
    font-size: 11px;
    line-height: 1;
    font-variation-settings: 'FILL' 1;
    flex: none;
}
.calendar-event-more {
    padding: 0 4px;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--md-sys-on-surface-variant);
    background: color-mix(in srgb, var(--md-sys-outline-variant) 30%, transparent);
    border-radius: 4px;
    text-align: center;
    overflow: hidden;
}

@media (prefers-color-scheme: dark) {
    .calendar-event {
        background: color-mix(in srgb, var(--event-color) 18%, var(--md-sys-surface-container-highest));
        color: color-mix(in srgb, var(--event-color) 35%, var(--md-sys-on-surface));
    }
}
.calendar-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--md-sys-outline-variant);
}
.calendar-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--md-sys-on-surface-variant);
}
.calendar-legend i {
    width: 9px;
    height: 9px;
    border-radius: var(--md-sys-shape-full);
    flex: none;
}



/* TASK-16: Today focus ring pulse (M3 Expressive) */
@keyframes m3e-ring-pulse {
    0%, 100% { transform: scale(1); filter: saturate(1) drop-shadow(0 0 0 transparent); }
    50% { transform: scale(1.03); filter: saturate(1.15) drop-shadow(0 6px 18px var(--md-sys-primary-container)); }
}
.today-focus-ring {
    animation: m3e-ring-pulse 4.8s var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1)) infinite;
    will-change: transform, filter;
}
.today-focus-ring > div { transition: transform .35s var(--md-expressive-spring); }
.today-focus-ring:hover > div { transform: scale(1.06); }
}
@layer components {
/* --- Record Tabs & Health --- */
.record-tabs,
.weight-range-tabs {
    display: flex;
    gap: 8px;
    margin: 8px 16px;
    padding: 4px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
}
.record-tab,
.weight-range {
    flex: 1;
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 38px;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.record-tab.active,
.weight-range.active {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}
.record-tab .material-symbols-rounded { font-size: 18px; }
.record-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    font-size: 20px;
    font-variation-settings: 'FILL' 1;
    flex: none;
}
.daily-summary-card {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.daily-stat {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 10px 4px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
}
.daily-stat .material-symbols-rounded { color: var(--md-sys-primary); font-variation-settings: 'FILL' 1; }
.daily-stat b { font-size: 20px; }
.daily-stat small { color: var(--md-sys-on-surface-variant); font-size: 11px; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.collapsible-head-btn {
    width: 100%;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.collapsible-head-btn:active .collapse-btn {
    transform: scale(0.94);
}
.panel-head h3 { font-size: 18px; line-height: 1.2; color: var(--md-sys-on-surface); }
.panel-head small { color: var(--md-sys-on-surface-variant); }
.collapse-btn {
    width: 40px; height: 40px; border: none; border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-secondary-container); color: var(--md-sys-on-secondary-container);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
    box-shadow: var(--md-sys-elevation-1);
}
.collapse-content {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    max-height: 1200px;
    opacity: 1;
    overflow: hidden;
    transition:
        max-height var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        margin-top var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.collapsed .collapse-content {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}
.collapsible-card.collapsed .panel-head { margin-bottom: 0; }
.collapsible-card {
    border-radius: 24px;
    box-shadow:
        0 10px 24px rgba(0, 29, 54, 0.05),
        inset 0 1px 0 rgba(255,255,255,0.18);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--md-sys-surface-container-lowest) 72%, transparent), var(--md-sys-surface-container-low)),
        var(--md-sys-surface-container-low);
}
.macro-summary {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.macro-summary div {
    padding: 10px 8px; border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest); display: grid; gap: 2px;
}
.macro-summary b { color: var(--md-sys-primary); font-size: 18px; }
.macro-summary small { color: var(--md-sys-on-surface-variant); font-size: 11px; }
.macro-progress-grid { gap: 10px; }
.macro-card {
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 65%, transparent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.24);
}
.macro-head { display: grid; gap: 2px; }
.macro-track {
    position: relative;
    height: 8px;
    margin-top: 4px;
    border-radius: var(--md-sys-shape-full);
    background: color-mix(in srgb, var(--md-sys-surface-container-highest) 75%, transparent);
    overflow: hidden;
}
.macro-track span {
    position: absolute;
    inset: 0 auto 0 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--md-sys-primary), var(--md-sys-primary-container));
}
.macro-card.protein .macro-track span { background: linear-gradient(90deg, #0061a4, #58a6ff); }
.macro-card.carb .macro-track span { background: linear-gradient(90deg, #8b5cf6, #c084fc); }
.macro-card.fat .macro-track span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.weight-open-btn {
    flex: none;
    margin-top: 0;
}
.weight-card { display: grid; gap: 14px; }
.weight-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.weight-head h3 {
    font-size: 34px;
    line-height: 1.05;
    color: var(--md-sys-primary);
}
.weight-head small { color: var(--md-sys-on-surface-variant); }
.weight-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-size: 30px;
    font-variation-settings: 'FILL' 1;
}
.weight-input-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.bmi-row {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.bmi-display {
    display: flex; align-items: baseline; gap: 6px; flex: 1;
}
.bmi-value { font-size: 28px; font-weight: 900; color: var(--md-sys-primary); }
.bmi-label { font-size: 13px; font-weight: 700; }
.bmi-range { font-size: 11px; color: var(--md-sys-on-surface-variant); }
.bmi-empty { color: var(--md-sys-on-surface-variant); }
.calendar-day { cursor: pointer; }
.calendar-day.selected {
    border-color: var(--md-sys-primary);
    box-shadow: 0 0 0 2px var(--md-sys-primary-container);
    background: color-mix(in srgb, var(--md-sys-primary-container) 20%, var(--md-sys-surface-container-lowest));
}
.day-detail-card { display: grid; gap: 10px; animation: fadeSlideIn 0.25s ease-out; }
.day-detail-head {
    display: flex; align-items: center; gap: 8px;
}
.day-detail-head .material-symbols-rounded { color: var(--md-sys-primary); font-variation-settings: 'FILL' 1; }
.day-detail-head strong { flex: 1; font-size: 16px; }
.day-detail-stats {
    display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--md-sys-on-surface-variant);
}
.day-detail-stats span {
    padding: 3px 10px; border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container); font-weight: 600;
}
.day-detail-section { display: grid; gap: 4px; }
.day-detail-section b { font-size: 13px; color: var(--md-sys-on-surface); margin-bottom: 2px; }
.day-detail-item {
    display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px;
    background: var(--md-sys-surface-container-lowest); border-radius: var(--md-sys-shape-sm); font-size: 13px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.14);
    max-width: 100%;
    min-width: 0;
}
.day-detail-item span:not(.material-symbols-rounded):not(.food-tag) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
}
.day-detail-item small {
    color: var(--md-sys-on-surface-variant);
    flex: none;
    max-width: 42%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
    line-height: 1.35;
}
.food-tag {
    flex: none !important; font-size: 10px !important; font-weight: 700; padding: 2px 8px;
    border-radius: var(--md-sys-shape-full); background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container); white-space: nowrap; overflow: visible; text-overflow: unset;
}



/* TASK-22: Day-detail item swipe-open (M3 Expressive) */
.day-detail-item {
    transition: transform .28s var(--md-expressive-spring);
    touch-action: pan-y;
}
.day-detail-item.swipe-open .delete-btn {
    background: var(--md-sys-error, #b3261e); color: #fff;
}
}
@layer components {
/* --- Diet Card --- */
.diet-card { display: grid; gap: 14px; }
.diet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}
.diet-head h3 { font-size: 28px; line-height: 1.05; color: var(--md-sys-primary); }
.diet-head .collapse-btn { position: relative; z-index: 1; }
.diet-head small { color: var(--md-sys-on-surface-variant); }
.food-source-tag {
    padding: 4px 10px;
    border-radius: var(--md-sys-shape-full);
    background: linear-gradient(135deg, var(--md-sys-primary-container), color-mix(in srgb, var(--md-sys-tertiary-container) 35%, var(--md-sys-primary-container)));
    color: var(--md-sys-on-primary-container);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2px;
    box-shadow: var(--md-sys-elevation-1);
}
.diet-icon {
    width: 48px; height: 48px; border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--md-sys-secondary-container); color: var(--md-sys-on-secondary-container);
    font-size: 26px; font-variation-settings: 'FILL' 1;
}
.diet-input-area { display: grid; gap: 8px; }
.diet-input-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.diet-btn-row { display: flex; gap: 6px; grid-column: 1 / -1; }
.diet-btn-row .md-btn-filled { flex: 1; margin-top: 0; }
.diet-btn-row .md-btn-tonal { flex: none; width: 48px; padding: 0; margin-top: 0; }
/* 编辑食物/运动行内操作按钮：统一两个按钮高度，去掉 filled 默认 margin-top */
.food-edit-actions { align-items: center; }
.food-edit-actions .md-btn,
.food-edit-actions .md-btn-tonal,
.food-edit-actions .md-btn-filled {
    height: 44px;
    margin-top: 0;
}
.food-search-results { display: grid; gap: 4px; max-height: 160px; overflow-y: auto; }
.food-result-item {
    border: none; background: var(--md-sys-surface-container-lowest); color: var(--md-sys-on-surface);
    padding: 8px 10px; border-radius: var(--md-sys-shape-md); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    text-align: left; font-size: 13px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.14);
}
.food-result-item:active { background: var(--md-sys-surface-container); }
.food-result-item small { color: var(--md-sys-on-surface-variant); white-space: nowrap; }
.food-ai-result { border-left: 3px solid var(--md-sys-tertiary); }
.food-ai-result-card { display: grid; gap: 6px; }
.food-add-all {
    border-left: 3px solid var(--md-sys-primary); background: color-mix(in srgb, var(--md-sys-primary-container) 15%, var(--md-sys-surface-container-lowest));
    font-weight: 700;
}
.food-add-all .material-symbols-rounded { font-size: 18px; color: var(--md-sys-primary); }
.food-added { opacity: 0.6; }
.food-added-badge {
    font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-secondary-container); color: var(--md-sys-on-secondary-container); white-space: nowrap;
}
.food-add-btn {
    border: none; width: 32px; height: 32px; border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.food-add-btn .material-symbols-rounded { font-size: 18px; }
.food-inline-edit-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px 10px 10px;
    border-radius: var(--md-sys-shape-md);
    background: color-mix(in srgb, var(--md-sys-surface-container) 80%, white);
}
.food-inline-edit-grid .md-field { margin-bottom: 0; }
.food-inline-actions { display: flex; justify-content: flex-end; gap: 8px; }
.food-ai-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--md-sys-tertiary);
    min-height: 16px;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.food-ai-cancel {
    border: none;
    border-radius: var(--md-sys-shape-full);
    padding: 3px 10px;
    background: var(--md-sys-error-container);
    color: var(--md-sys-on-error-container);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    flex: none;
}
.diet-photo-spin {
    animation: diet-photo-spin 0.9s linear infinite;
}

@keyframes diet-photo-spin {
    to {
        transform: rotate(360deg);
    }
}
.food-computed {
    font-size: 12px;
    color: var(--md-sys-on-surface-variant);
    padding: 8px 10px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
    border: 1px dashed var(--md-sys-outline-variant);
}
.food-source-hint {
    font-size: 11px;
    line-height: 1.45;
    color: var(--md-sys-on-surface-variant);
    padding: 8px 10px;
    border-radius: 14px;
    background: var(--md-sys-surface-container);
}
.food-source-hint.active {
    color: var(--md-sys-on-primary-container);
    background: color-mix(in srgb, var(--md-sys-primary-container) 70%, var(--md-sys-surface-container));
}
.food-cal-hint {
    font-size: 11px;
    line-height: 1.45;
    color: var(--md-sys-tertiary);
    padding: 0 2px;
}
.food-source-tag {
    padding: 4px 10px;
    border-radius: var(--md-sys-shape-full);
    background: linear-gradient(135deg, var(--md-sys-primary-container), color-mix(in srgb, var(--md-sys-tertiary-container) 35%, var(--md-sys-primary-container)));
    color: var(--md-sys-on-primary-container);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2px;
    box-shadow: var(--md-sys-elevation-1);
}
.diet-meal-group { display: grid; gap: 6px; margin-top: 8px; }
.diet-meal-head {
    width: 100%;
    border: none;
    padding: 8px 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-align: left;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.diet-meal-head::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.diet-meal-head:hover { box-shadow: var(--md-sys-elevation-1); }
.diet-meal-head:hover::after { opacity: var(--md-state-hover); }
.diet-meal-head:active { transform: scale(0.985); background: var(--md-sys-surface-container-high); }
.diet-meal-head:active::after { opacity: var(--md-state-press); }
.diet-meal-head > * { position: relative; z-index: 1; }
.diet-meal-head strong {
    flex: 1; font-size: 13px; font-weight: 800; color: var(--md-sys-on-surface);
}
.diet-meal-head small {
    font-size: 12px; font-weight: 700; color: var(--md-sys-primary);
}
.diet-meal-head .material-symbols-rounded { font-size: 18px; color: var(--md-sys-on-surface-variant); }
.diet-meal-content { display: grid; gap: 4px; }
.diet-meal-group.collapsed .diet-meal-content { display: none; }

/* Diet Mode Tabs */
.diet-mode-tabs {
    display: flex;
    gap: 8px;
    padding: 4px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
}
.diet-mode-tab {
    flex: 1;
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 38px;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    font-weight: 700;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
.diet-mode-tab.active {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    box-shadow: var(--md-sys-elevation-1);
}
.diet-mode-tab .material-symbols-rounded { font-size: 18px; }
.diet-meal-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.diet-meal-pill {
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 32px;
    padding: 0 14px;
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
.diet-meal-pill.active {
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    box-shadow: var(--md-sys-elevation-1);
}
.diet-ai-entry {
    display: grid;
    gap: 8px;
}
.diet-ai-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.diet-ai-actions .md-btn {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    height: 44px;
    margin-top: 0;
    padding: 0 10px;
    justify-content: center;
    white-space: nowrap;
}

@media (max-width: 360px) {
    .diet-ai-actions {
        grid-template-columns: 1fr;
    }
}
.diet-ai-input {
    width: 100%;
    min-height: 20px;
    max-height: 120px;
    resize: none;
    overflow-y: auto;
    border: none;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-highest);
    color: var(--md-sys-on-surface);
    font: inherit;
    font-size: 14px;
    line-height: 1.35;
    padding: 10px 12px;
    outline: none;
    transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.diet-ai-input::placeholder {
    color: var(--md-sys-on-surface-variant);
    opacity: 0.7;
}
.diet-ai-input:focus {
    box-shadow:
        0 2px 6px 2px rgba(0,0,0,0.08),
        0 0 0 2px color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
}
.diet-ai-run {
    justify-self: start;
    margin-top: 0;
}
.diet-suggest-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.diet-suggest-chip {
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 30px;
    padding: 0 12px;
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.diet-suggest-chip:active { transform: scale(0.98); }
.diet-manual-area { display: grid; gap: 8px; }
.diet-meal-title {
    font-size: 13px; font-weight: 800; color: var(--md-sys-on-surface); margin-bottom: 4px;
    display: flex; align-items: center; gap: 6px;
}
.diet-meal-title small { font-weight: 600; color: var(--md-sys-primary); }
.diet-log-item {
    display: grid; gap: 4px; padding: 8px 10px;
    background: var(--md-sys-surface-container-lowest); border-radius: var(--md-sys-shape-sm); margin-bottom: 3px;
    font-size: 13px;
    min-width: 0;
}
.diet-log-main {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    min-width: 0;
}
.diet-log-name {
    flex: 1 1 auto; min-width: 0; font-weight: 600; color: var(--md-sys-on-surface);
    overflow-wrap: anywhere; word-break: break-word;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.diet-log-cal { flex: 0 0 auto; white-space: nowrap; color: var(--md-sys-primary); font-size: 13px; font-weight: 700; }
.diet-log-sub {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    min-width: 0;
}
.diet-log-sub small {
    flex: 1 1 auto; min-width: 0; color: var(--md-sys-on-surface-variant); font-size: 11px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.diet-log-actions { display: flex; gap: 2px; flex: 0 0 auto; align-items: center; }
.diet-log-actions .delete-btn,
.diet-log-actions .food-log-action-btn { opacity: 1; }
.food-log-action-btn {
    border: none;
    width: 30px;
    height: 30px;
    border-radius: var(--md-sys-shape-full);
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.food-log-action-btn .material-symbols-rounded { font-size: 17px; }
.diet-log-editor {
    display: grid;
    gap: 8px;
    margin-bottom: 6px;
    padding: 10px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
}
.exercise-grid { margin: 0; }
.manual-ex-list { display: grid; gap: 4px; }
}
@layer components {
/* --- Weight Loss Plan --- */
.weightloss-card { display: grid; gap: 14px; }
.weightloss-card,
.diet-card,
.weight-card,
.collapsible-card,
.calendar-card,
.day-detail-card {
    position: relative;
}
.weightloss-card::before,
.diet-card::before,
.weight-card::before,
.collapsible-card::before,
.calendar-card::before,
.day-detail-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.14);
}
.weightloss-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.weightloss-head h3 { font-size: 20px; line-height: 1.2; color: var(--md-sys-on-surface); }
.weightloss-head small { color: var(--md-sys-on-surface-variant); }
.weightloss-icon {
    width: 48px; height: 48px; border-radius: 16px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--md-sys-tertiary-container); color: var(--md-sys-on-tertiary-container);
    font-size: 26px; font-variation-settings: 'FILL' 1;
}
.weightloss-form { display: grid; gap: 10px; }
.weightloss-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.weightloss-options { display: grid; gap: 8px; }
.weightloss-option {
    padding: 12px; border-radius: var(--md-sys-shape-lg);
    border: 2px solid var(--md-sys-outline-variant); cursor: pointer;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    background: var(--md-sys-surface-container-lowest);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.weightloss-option:active { transform: scale(0.98); }
.weightloss-option.active {
    border-color: var(--md-sys-primary);
    background: color-mix(in srgb, var(--md-sys-primary-container) 18%, var(--md-sys-surface-container-lowest));
    box-shadow:
        0 8px 20px rgba(0, 97, 164, 0.12),
        inset 0 1px 0 rgba(255,255,255,0.22);
}
.weightloss-option-head {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.weightloss-option-head b { font-size: 15px; }
.weightloss-option-stats {
    display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--md-sys-on-surface-variant);
    margin-bottom: 4px;
}
.weightloss-option-stats b { color: var(--md-sys-primary); font-size: 16px; margin-left: auto; }
.weightloss-option small { color: var(--md-sys-on-surface-variant); font-size: 12px; }
.weightloss-tips {
    display: grid; gap: 4px; margin-top: 8px;
    padding: 10px; border-radius: var(--md-sys-shape-lg); background: var(--md-sys-surface-container);
}
.weightloss-tips span {
    display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--md-sys-on-surface-variant);
}
.weightloss-tips .material-symbols-rounded { font-size: 16px; color: var(--md-sys-primary); font-variation-settings: 'FILL' 1; }

/* --- Goal Mode Tabs --- */
.goal-mode-tabs {
    display: flex;
    gap: 8px;
    padding: 4px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
}
.goal-mode-tab {
    flex: 1;
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 38px;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    font-weight: 700;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
.goal-mode-tab.active {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    box-shadow: var(--md-sys-elevation-1);
}
.goal-mode-tab .material-symbols-rounded { font-size: 18px; }

/* --- Gain mode color variants --- */
.goal-gain .weightloss-icon {
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
}
.goal-gain .weightloss-option.active {
    border-color: var(--md-sys-tertiary);
    background: color-mix(in srgb, var(--md-sys-tertiary-container) 18%, var(--md-sys-surface-container-lowest));
    box-shadow:
        0 8px 20px rgba(130, 71, 229, 0.12),
        inset 0 1px 0 rgba(255,255,255,0.22);
}
.goal-gain .weightloss-option-stats b { color: var(--md-sys-tertiary); }
.goal-gain .weightloss-tips .material-symbols-rounded { color: var(--md-sys-tertiary); }

/* --- Loss mode color variants --- */
.goal-loss .weightloss-icon {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}
.goal-loss .weightloss-option.active {
    border-color: var(--md-sys-primary);
    background: color-mix(in srgb, var(--md-sys-primary-container) 18%, var(--md-sys-surface-container-lowest));
    box-shadow:
        0 8px 20px rgba(0, 97, 164, 0.12),
        inset 0 1px 0 rgba(255,255,255,0.22);
}

/* --- Goal Guide (collapsible help) --- */
.goal-guide {
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container);
    overflow: hidden;
}
.goal-guide summary {
    min-height: 40px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--md-sys-on-surface);
    font-size: 13px;
    font-weight: 800;
    list-style: none;
}
.goal-guide summary::-webkit-details-marker { display: none; }
.goal-guide summary .material-symbols-rounded { font-size: 18px; color: var(--md-sys-primary); }
.goal-guide-content {
    display: grid;
    gap: 8px;
    padding: 0 12px 12px;
}
.goal-guide-content div {
    padding: 8px 10px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
}
.goal-guide-content b {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--md-sys-on-surface);
}
.goal-guide-content p,
.goal-guide-content ul {
    margin: 0;
    padding: 0;
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    line-height: 1.45;
}
.goal-guide-content ul { padding-left: 16px; }
.goal-guide-content li { margin: 2px 0; }

/* --- Mobile responsive (goal card) --- */
@media (max-width: 480px) {
    .weightloss-card { gap: 10px; }
    .weightloss-head { gap: 8px; }
    .weightloss-head > div { min-width: 0; }
    .weightloss-head small { display: block; overflow-wrap: anywhere; line-height: 1.35; }
    .weightloss-icon { width: 40px; height: 40px; border-radius: 14px; font-size: 22px; }
    .weightloss-grid { grid-template-columns: 1fr; gap: 8px; }
    .goal-mode-tabs { gap: 4px; }
    .goal-mode-tab { min-height: 34px; font-size: 12px; }
    .weightloss-option { padding: 10px; }
    .weightloss-option-stats { gap: 6px; font-size: 12px; flex-wrap: wrap; }
    .weightloss-option-stats b { margin-left: 0; font-size: 15px; }
    .goal-guide summary { min-height: 36px; padding: 0 10px; font-size: 12px; }
    .goal-guide-content { padding: 0 10px 10px; }
}
@media (max-width: 360px) {
    .weightloss-card { gap: 8px; }
    .weightloss-head h3 { font-size: 17px; }
    .weightloss-option-head b { font-size: 14px; }
    .weightloss-option-stats { font-size: 11px; }
}

}
@layer components {
/* --- AI Config --- */
.ai-card-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.ai-card-header .material-symbols-rounded { font-size: 22px; color: var(--md-sys-tertiary); font-variation-settings: 'FILL' 1; }
.ai-card-header strong { flex: 1; }
.ai-status {
    font-size: 11px; font-weight: 700; padding: 2px 10px;
    border-radius: var(--md-sys-shape-full);
}
.ai-ready { background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); }
.ai-off { background: var(--md-sys-surface-container-high); color: var(--md-sys-on-surface-variant); }
.ai-model-list {
    display: grid; gap: 4px; max-height: 200px; overflow-y: auto;
    padding: 6px; border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container); margin: 6px 0;
}
.ai-model-item {
    border: none; background: var(--md-sys-surface-container-lowest); color: var(--md-sys-on-surface);
    padding: 8px 10px; border-radius: var(--md-sys-shape-md); cursor: pointer;
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    text-align: left; font-size: 13px; transition: background 0.15s;
}
.ai-model-item:active { background: var(--md-sys-surface-container); }
.ai-model-item.has-vision { border-left: 3px solid var(--md-sys-primary); }
.ai-model-item.is-imagegen { border-left: 3px solid var(--md-sys-tertiary); }
.ai-model-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-vision-badge {
    display: inline-flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700;
    padding: 2px 8px; border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); white-space: nowrap;
}
.ai-vision-badge .material-symbols-rounded { font-size: 12px; }
.ai-vision-badge-highres {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.ai-vision-badge-imagegen {
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
}
.ai-vision-badge-unverified {
    background: var(--md-sys-surface-container-high);
    color: var(--md-sys-on-surface-variant);
}
.ai-model-empty { text-align: center; padding: 12px; color: var(--md-sys-on-surface-variant); font-size: 13px; }
.ai-profile-actions {
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    margin-bottom: 8px;
}
.ai-profile-actions .md-field {
    margin: 0 !important;
    display: flex;
    flex: 1 1 160px;
    min-width: 0;
}
.ai-profile-actions .md-field input,
.ai-profile-actions .md-field select {
    height: 48px;
    box-sizing: border-box;
}
.ai-profile-actions .md-btn {
    flex: none;
    margin: 0 !important;
    white-space: nowrap;
    padding: 0 14px;
    height: 48px;
    box-sizing: border-box;
    font-size: 13px;
    align-self: center;
}
.ai-profile-actions .md-btn .material-symbols-rounded { font-size: 18px; }
.ai-encrypt-section {
    display: grid; gap: 8px; padding-top: 10px; margin-top: 10px;
    border-top: 1px solid var(--md-sys-outline-variant);
}
.ai-encrypt-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 700; color: var(--md-sys-on-surface);
}
.ai-encrypt-title .material-symbols-rounded { font-size: 18px; color: var(--md-sys-tertiary); }
.ai-encrypt-section small { color: var(--md-sys-on-surface-variant); font-size: 11px; line-height: 1.4; }
.ai-template-actions {
    gap: 8px;
    flex-wrap: nowrap;
}
.ai-template-actions .md-btn {
    min-width: 0;
    padding: 0 12px;
    white-space: nowrap;
}
.ai-template-actions .material-symbols-rounded {
    font-size: 18px;
}

.password-visibility-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    padding: 0;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    transition:
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring);
}

.password-visibility-toggle::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.password-visibility-toggle:hover,
.password-visibility-toggle:focus-visible {
    color: var(--md-sys-primary);
}

.password-visibility-toggle:hover::after,
.password-visibility-toggle:focus-visible::after {
    opacity: var(--md-state-hover);
}

.password-visibility-toggle:active {
    transform: translateY(-50%) scale(.94);
}

.password-visibility-toggle:active::after {
    opacity: var(--md-state-press);
}

.md-field-has-action:focus-within .password-visibility-toggle {
    color: var(--md-sys-primary);
}

.password-visibility-toggle .material-symbols-rounded {
    position: relative;
    z-index: 1;
    font-size: 22px;
    line-height: 1;
}

/* 凭据字段：避开 type=password 触发的密码管理器，靠 CSS 实现密文外观 */
.credential-masked {
    -webkit-text-security: disc;
    text-security: disc;
    letter-spacing: var(--md-sys-typescale-body-large-letter-spacing, 0);
    font-family: inherit;
    caret-color: var(--md-sys-primary);
}

}
@layer components {
/* --- Rate Row --- */
.rate-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--md-sys-on-surface-variant);
    font-weight: 500;
}
.rate-row input[type="range"] {
    flex: 1;
    accent-color: var(--md-sys-primary);
    padding: 0;
    border: none;
    height: 4px;
}

}
@layer components {
/* --- Mode Tabs --- */
.mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 16px;
    padding: 4px;
    border-radius: 22px;
    background: var(--md-sys-surface-container-low);
    border: 1px solid var(--md-sys-outline-variant);
}
.mode-tab {
    height: 44px;
    border: none;
    border-radius: 18px;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        color var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        border-radius var(--md-sys-motion-duration-medium) var(--md-expressive-spring);
}
.mode-tab::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.mode-tab:hover::after { opacity: var(--md-state-hover); }
.mode-tab .material-symbols-rounded {
    font-size: 20px;
    position: relative;
    z-index: 1;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        font-variation-settings var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
.mode-tab.active {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    box-shadow: var(--md-sys-elevation-1);
    border-radius: 20px;
}
.mode-tab.active .material-symbols-rounded {
    transform: translateY(-1px) scale(1.08);
    font-variation-settings: 'FILL' 1;
}
.mode-tab:active { transform: scale(0.96); }
.mode-tab:active::after { opacity: var(--md-state-press); }

@media (max-width: 480px) {
    .mode-tab { font-size: 12px; gap: 4px; height: 38px; }
    .mode-tab .material-symbols-rounded { font-size: 18px; }
}

}
@layer components {
/* --- Routine Tool --- */
.routine-tool {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}
.routine-tool input { flex: 1; }
.routine-tool .md-btn { flex: none; white-space: nowrap; margin-top: 0; width: auto; }

}
@layer components {
/* --- Routine Card --- */
.routine-card {
    background: var(--md-sys-surface-container-lowest);
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    margin: 6px 16px;
    overflow: hidden;
    transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.routine-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.routine-card-head:active { background: var(--md-sys-surface-container); }
.routine-card-head strong { font-size: 15px; font-weight: 600; display: block; color: var(--md-sys-on-surface); }
.routine-card-head small { color: var(--md-sys-on-surface-variant); font-size: 12px; }
.routine-expand-icon {
    font-size: 22px;
    color: var(--md-sys-on-surface-variant);
    transition: transform var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.routine-action-list {
    padding: 0 16px 14px;
    display: grid;
    gap: 4px;
    animation: fadeSlideIn 0.2s ease-out;
}
.routine-action-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--md-sys-shape-sm);
    background: var(--md-sys-surface-container-lowest);
    font-size: 13px;
    flex-wrap: wrap;
}
.routine-action-item .routine-action-name { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; word-break: break-word; }
.routine-action-item small { color: var(--md-sys-on-surface-variant); white-space: nowrap; font-size: 11px; }
.routine-action-idx {
    width: 22px;
    height: 22px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.routine-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--md-sys-outline-variant);
}
.routine-inline-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex: none;
}
.routine-inline-actions .icon-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.routine-inline-actions .icon-btn .material-symbols-rounded {
    font-size: 16px;
}
@media (max-width: 480px) {
    .library-segment-wrap {
        margin: 6px 8px 4px;
    }
    .library-segment-btn {
        gap: 4px;
        padding: 0 4px;
        min-height: 34px;
    }
    .library-card-actions .md-btn {
        padding: 0 8px;
        font-size: 12px;
        gap: 4px;
    }
    .routine-action-item {
        gap: 6px;
        padding: 6px 8px;
    }
    .routine-inline-actions {
        margin-left: auto;
        gap: 1px;
    }
    .routine-inline-actions .icon-btn {
        width: 26px;
        height: 26px;
    }
    .routine-inline-actions .icon-btn .material-symbols-rounded {
        font-size: 15px;
    }
}
@media (max-width: 360px) {
    .library-segment-btn {
        min-height: 32px;
        padding: 0 2px;
    }
    /* Removed .library-segment-btn .library-segment-label display:none to restore missing text */
    .library-card-actions {
        gap: 4px;
        grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    }
    .library-card-actions .md-btn {
        height: 32px;
        padding: 0 6px;
        font-size: 11px;
    }
    .library-card-actions .md-btn span:last-child {
        display: none;
    }
    /* Removed display: none for up/down buttons */
    .routine-inline-actions .icon-btn {
        width: 24px;
        height: 24px;
    }
    .routine-inline-actions .icon-btn .material-symbols-rounded {
        font-size: 14px;
    }
}

}
@layer components {
/* --- Cardio Timer --- */
.cardio-card {
    display: grid;
    gap: 14px;
}
.cardio-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.cardio-header h3 {
    font-size: 18px;
    line-height: 1.2;
    color: var(--md-sys-on-surface);
}
.cardio-kicker {
    display: block;
    margin-bottom: 2px;
    color: var(--md-sys-primary);
    font-size: 11px;
    font-weight: 900;
}
.cardio-header > .material-symbols-rounded {
    width: 42px;
    height: 42px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    font-variation-settings: 'FILL' 1;
}
.cardio-grid { margin: 0; }
body.is-cardio .cardio-card {
    box-shadow:
        0 10px 28px rgba(0, 29, 54, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: color-mix(in srgb, var(--md-sys-primary) 28%, var(--md-sys-outline-variant));
}
body.is-cardio .cardio-header > .material-symbols-rounded {
    background: var(--md-sys-primary);
    color: var(--md-sys-on-primary);
}
body.is-cardio-paused .cardio-card {
    border-color: color-mix(in srgb, var(--md-sys-tertiary) 32%, var(--md-sys-outline-variant));
}

}
@layer components {
/* --- Sync Card --- */
.sync-card { padding: 20px; }
.theme-card { padding: 16px; }
.sync-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--md-sys-on-surface);
}
.sync-actions { margin-top: 16px; }
.sync-actions .md-btn { margin-top: 8px; }
.sync-actions .md-row .md-btn { margin-top: 0; }
.sync-card .md-field { margin-bottom: 8px; }
.sync-backup-row { flex-wrap: wrap; }
.sync-detail-status {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.sync-meta-item {
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
    display: grid;
    gap: 2px;
}
.sync-meta-item strong { font-size: 11px; color: var(--md-sys-on-surface-variant); }
.sync-meta-item span { font-size: 12px; color: var(--md-sys-on-surface); }
.sync-meta-wide { grid-column: 1 / -1; }

.voice-sheet-card {
    width: min(94vw, 560px);
    gap: 14px;
}
.voice-sheet-card .md-modal-head strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.voice-sheet-card .md-modal-head .material-symbols-rounded {
    color: var(--md-sys-primary);
    font-size: 22px;
    font-variation-settings: 'FILL' 1;
}
.voice-top-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}
.voice-top-actions .md-btn {
    min-width: 0;
    height: 44px;
}
.voice-mode-card {
    --voice-mode-a: var(--md-sys-primary-container);
    --voice-mode-b: var(--md-sys-surface-container-low);
    --voice-mode-border: color-mix(in srgb, var(--md-sys-primary) 24%, transparent);
    min-height: 76px;
    border: 1px solid var(--voice-mode-border);
    border-radius: var(--md-sys-shape-lg);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--voice-mode-a), var(--voice-mode-b));
    color: var(--md-sys-on-surface);
    transition:
        background var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        border-color var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring);
}
.voice-mode-card[data-mode="online-first"] {
    --voice-mode-a: var(--md-sys-primary-container);
    --voice-mode-b: color-mix(in srgb, var(--md-sys-primary-container) 34%, var(--md-sys-surface-container-lowest));
    --voice-mode-border: color-mix(in srgb, var(--md-sys-primary) 28%, transparent);
    --voice-mode-icon-bg: color-mix(in srgb, var(--md-sys-primary) 14%, var(--md-sys-surface-container-lowest));
    --voice-mode-icon-fg: var(--md-sys-primary);
}
.voice-mode-card[data-mode="local-first"] {
    --voice-mode-a: var(--md-sys-secondary-container);
    --voice-mode-b: color-mix(in srgb, var(--md-sys-secondary-container) 34%, var(--md-sys-surface-container-lowest));
    --voice-mode-border: color-mix(in srgb, var(--md-sys-secondary) 28%, transparent);
    --voice-mode-icon-bg: color-mix(in srgb, var(--md-sys-secondary) 14%, var(--md-sys-surface-container-lowest));
    --voice-mode-icon-fg: var(--md-sys-secondary);
}
.voice-mode-card[data-mode="online-only"] {
    --voice-mode-a: var(--md-sys-tertiary-container);
    --voice-mode-b: color-mix(in srgb, var(--md-sys-tertiary-container) 34%, var(--md-sys-surface-container-lowest));
    --voice-mode-border: color-mix(in srgb, var(--md-sys-tertiary) 28%, transparent);
    --voice-mode-icon-bg: color-mix(in srgb, var(--md-sys-tertiary) 14%, var(--md-sys-surface-container-lowest));
    --voice-mode-icon-fg: var(--md-sys-tertiary);
}
.voice-mode-card[data-mode="local-only"] {
    --voice-mode-a: var(--md-sys-surface-container-high);
    --voice-mode-b: var(--md-sys-surface-container-lowest);
    --voice-mode-border: color-mix(in srgb, var(--md-sys-outline) 24%, transparent);
    --voice-mode-icon-bg: var(--md-sys-surface-container-highest);
    --voice-mode-icon-fg: var(--md-sys-on-surface-variant);
}
.voice-mode-card > .material-symbols-rounded {
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-md);
    display: inline-grid;
    place-items: center;
    background: var(--voice-mode-icon-bg, color-mix(in srgb, var(--md-sys-primary) 14%, var(--md-sys-surface-container-lowest)));
    color: var(--voice-mode-icon-fg, var(--md-sys-primary));
    font-size: 21px;
    font-variation-settings: 'FILL' 1;
    transition:
        background var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        color var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring);
}
.voice-mode-card div {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.voice-mode-card strong { font-size: 16px; }
.voice-mode-card small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    font-weight: 650;
}
.voice-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-sys-on-surface);
}
.voice-card-header .material-symbols-rounded {
    color: var(--md-sys-primary);
    font-size: 22px;
    font-variation-settings: 'FILL' 1;
}
.voice-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--md-sys-on-surface-variant);
}
.voice-section-head {
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.voice-section-head .voice-section-title {
    min-width: 0;
}
.voice-section-action {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    color: var(--md-sys-on-surface-variant);
    background: var(--md-sys-surface-container-low);
}
.voice-section-action:hover {
    color: var(--md-sys-primary);
    background: color-mix(in srgb, var(--md-sys-primary-container) 42%, var(--md-sys-surface-container-low));
}
.voice-section-action .material-symbols-rounded {
    font-size: 20px;
}
.voice-priority-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}
.voice-priority-option,
.voice-cache-toggle {
    min-height: 42px;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-sys-on-surface);
    background: var(--md-sys-surface-container-lowest);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.voice-priority-option {
    justify-content: flex-start;
}
.voice-priority-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.voice-priority-option .material-symbols-rounded {
    width: 24px;
    height: 24px;
    border-radius: var(--md-sys-shape-full);
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--md-sys-surface-container-high);
    color: var(--md-sys-on-surface-variant);
    font-size: 17px;
    font-variation-settings: 'FILL' 0;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short),
        color var(--md-sys-motion-duration-short),
        font-variation-settings var(--md-sys-motion-duration-short);
}
.voice-priority-option strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 750;
    line-height: 1;
}
.voice-priority-option:hover {
    background: var(--md-sys-surface-container-low);
}
.voice-priority-option:active {
    transform: scale(0.98);
}
.voice-priority-option:has(input:focus-visible) {
    outline: 2px solid var(--md-sys-primary);
    outline-offset: 2px;
}
.voice-priority-option:has(input:checked) {
    border-color: var(--md-sys-primary);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--md-sys-primary-container) 86%, transparent), var(--md-sys-surface-container-lowest));
    color: var(--md-sys-on-primary-container);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
}
.voice-priority-option:has(input:checked) .material-symbols-rounded {
    background: var(--md-sys-primary);
    color: var(--md-sys-on-primary);
    transform: scale(1.08);
    font-variation-settings: 'FILL' 1;
}
.voice-engine-list { display: grid; gap: 8px; }
.voice-empty,
.voice-status {
    font-size: 12px;
    color: var(--md-sys-on-surface-variant);
}
.voice-status[data-type="ok"] { color: var(--md-sys-primary); }
.voice-status[data-type="warn"] { color: #8a5a00; }
.voice-status[data-type="error"] { color: var(--md-sys-error); }
.voice-engine-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
}
.voice-engine-item:hover {
    background: var(--md-sys-surface-container-low);
}
.voice-engine-main {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.voice-engine-main strong,
.voice-engine-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.voice-engine-main strong { font-size: 13px; color: var(--md-sys-on-surface); }
.voice-engine-main small { font-size: 11px; color: var(--md-sys-on-surface-variant); }
.voice-engine-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
}
.voice-engine-actions .icon-btn {
    width: 34px;
    height: 34px;
}
.voice-editor {
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    padding: 12px;
    background: var(--md-sys-surface-container-low);
    display: grid;
    gap: 10px;
}
.voice-import-dialog {
    z-index: 240;
}
.voice-import-card {
    width: min(92vw, 520px);
    max-width: calc(100vw - 32px);
    gap: 14px;
}
.voice-import-card .md-modal-head strong {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.voice-import-card .md-modal-head .material-symbols-rounded {
    color: var(--md-sys-primary);
    font-size: 22px;
    font-variation-settings: 'FILL' 1;
}
.voice-import-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
}
.voice-import-actions .md-btn {
    width: 100%;
    height: 44px;
    min-height: 44px;
    margin-top: 0;
    justify-content: center;
}
.voice-speed-grid {
    display: grid;
    grid-template-columns: minmax(110px, 0.6fr) minmax(0, 1.4fr);
    gap: 8px;
}
.voice-json-field textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 132px;
    max-height: min(48vh, 360px);
    box-sizing: border-box;
    resize: none;
    overflow-y: hidden;
    border: 1.5px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface);
    font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
    padding: 24px 12px 10px;
    outline: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    transition:
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        height var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.voice-json-field textarea:focus {
    border-color: var(--md-sys-primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-primary) 14%, transparent);
}
.voice-json-field textarea::placeholder {
    color: transparent;
}
.voice-json-field label {
    top: 7px;
    transform: none;
    font-size: 10px;
    color: var(--md-sys-primary);
    font-weight: 600;
}
.voice-actions,
.voice-cache-row,
.voice-test-row {
    flex-wrap: wrap;
}
.voice-cache-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.voice-test-input { flex: 1 1 220px; }

@media (max-width: 520px) {
    .voice-priority-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .voice-speed-grid { grid-template-columns: 1fr; }
    .voice-engine-item {
        align-items: flex-start;
        flex-direction: column;
    }
    .voice-engine-actions { width: 100%; justify-content: flex-end; }
}

}
@layer components {
/* --- Bottom Navigation Rail (M3 Expressive) --- */
.md-nav-rail {
    position: relative;
    bottom: auto;
    width: 100%;
    height: calc(76px + env(safe-area-inset-bottom));
    flex: none;
    background: color-mix(in srgb, var(--md-sys-surface-container) 80%, transparent);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    z-index: 10;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid color-mix(in srgb, var(--md-sys-surface-container-lowest) 50%, transparent);
    box-shadow: 0 -1px 0 var(--md-sys-outline-variant);
}
.nav-item {
    flex: 1;
    border: none;
    background: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    padding: 0;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    height: 64px;
    min-width: 0;
}
.nav-content {
    width: 100%;
    height: 56px;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: var(--md-sys-shape-full);
    overflow: hidden;
    isolation: isolate;
}
/* Ripple inside the bottom-nav pill: subtle tonal layer instead of grey rectangle */
.nav-item .nav-content > .ripple {
    background: color-mix(in srgb, var(--md-sys-on-surface) 14%, transparent);
}
.nav-item.active .nav-content > .ripple {
    background: color-mix(in srgb, var(--md-sys-on-secondary-container) 18%, transparent);
}
.nav-item .material-symbols-rounded {
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        width var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        color var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        font-variation-settings var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
.nav-indicator {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 56px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-secondary-container);
    transition:
        width var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        height var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        border-radius var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
    z-index: 0;
}
.nav-item small {
    display: block;
    width: 100%;
    font-size: 12px;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}
.nav-item.active { color: var(--md-sys-on-surface); }
.nav-item.active .material-symbols-rounded {
    width: 54px;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-secondary-container);
    font-variation-settings: 'FILL' 1;
    transform: translateY(-1px) scale(1.08);
}
.nav-item.active .nav-indicator {
    width: 0;
    border-radius: 24px;
}
.nav-item.active small { font-weight: 700; color: var(--md-sys-on-secondary-container); }

.nav-item.active .nav-content > .material-symbols-rounded {
    view-transition-name: nav-pill;
}
::view-transition-old(nav-pill),
::view-transition-new(nav-pill) {
    animation-duration: 350ms;
    animation-timing-function: var(--md-sys-motion-spring);
}


}
@layer components {
/* --- FAB (Expressive) --- */
.workout-controls {
    position: fixed;
    left: 50%;
    bottom: calc(92px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 0;
    margin: 0;
    padding: 10px 12px;
    border: none;
    border-radius: 34px;
    background: rgba(244, 243, 250, 0.76);
    background:
        linear-gradient(135deg, rgba(255,255,255,0.72), rgba(244,243,250,0.42)),
        color-mix(in srgb, var(--md-sys-primary-container) 18%, transparent);
    box-shadow:
        0 14px 36px rgba(0, 29, 54, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(22px) saturate(1.35);
    -webkit-backdrop-filter: blur(22px) saturate(1.35);
    z-index: 95;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        box-shadow var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
}
body.is-training .workout-controls {
    transform: translateX(-50%) translateY(-4px);
    box-shadow:
        0 18px 44px rgba(0, 29, 54, 0.22),
        0 6px 16px rgba(0, 0, 0, 0.14);
}
.md-fab {
    width: 64px;
    height: 64px;
    border-radius: 22px;
    border: none;
    box-shadow:
        0 6px 18px rgba(0, 29, 54, 0.18),
        0 2px 6px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        border-radius var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        width var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        height var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        box-shadow var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    position: relative;
    overflow: hidden;
}
.md-fab:hover {
    box-shadow:
        0 10px 24px rgba(0, 29, 54, 0.22),
        0 3px 8px rgba(0, 0, 0, 0.14);
}
.md-fab::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.md-fab:active { transform: scale(0.92); }
.md-fab:hover::after { opacity: var(--md-state-hover); }
.md-fab:active::after { opacity: var(--md-state-press); }
.md-fab .material-symbols-rounded { font-size: 24px; position: relative; z-index: 1; }
.fab-play {
    width: auto;
    min-width: 136px;
    height: 68px;
    border-radius: 20px;
    padding: 0 22px;
    gap: 8px;
}
body.is-training .fab-play {
    width: 56px;
    min-width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 28px;
}
body.is-paused .fab-play {
    width: 72px;
    min-width: 72px;
    border-radius: 18px 30px 18px 30px;
}
.fab-play .material-symbols-rounded { font-size: 32px; }
.fab-label {
    position: relative;
    z-index: 1;
    font-size: 15px;
    font-weight: 850;
    white-space: nowrap;
}
body.is-training .fab-label { display: none; }
.fab-play {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}
body.is-training .fab-play {
    background: var(--md-sys-primary);
    color: var(--md-sys-on-primary);
}
body.is-paused .fab-play {
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
}
.fab-stop {
    background: var(--md-sys-error-container);
    color: var(--md-sys-on-error-container);
    width: 52px;
    height: 52px;
    border-radius: 18px;
}
.fab-stop > span {
    z-index: 1;
}
body.is-training .fab-stop {
    border-radius: 26px 18px 26px 18px;
}
.fab-pip {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
    width: 52px;
    height: 52px;
    border-radius: 18px;
}
.fab-pip.active {
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    border-radius: 26px;
    box-shadow:
        0 8px 22px color-mix(in srgb, var(--md-sys-tertiary) 26%, transparent),
        0 2px 8px rgba(0, 0, 0, 0.14);
}
.fab-pip.unsupported {
    opacity: 0.72;
}
body.is-training .fab-pip {
    border-radius: 18px 26px 18px 26px;
}
body.is-training .fab-pip.active {
    border-radius: 28px;
}


}
@layer components {
/* --- Skip Button --- */
.skip-btn {
    position: absolute;
    right: 12px;
    top: 12px;
    opacity: 0.4;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--md-sys-shape-sm);
    transition: opacity var(--md-sys-motion-duration-short);
}
.skip-btn:active { opacity: 1; }

}
@layer components {
/* --- Toast --- */
.md-toast {
    position: fixed;
    left: 50%;
    bottom: calc(96px + env(safe-area-inset-bottom));
    transform: translate(-50%, 12px);
    min-width: min(88vw, 360px);
    max-width: 92vw;
    padding: 12px 16px;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-inverse-surface);
    color: var(--md-sys-inverse-on-surface);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    box-shadow: var(--md-sys-elevation-3);
    z-index: 200;
    transition: opacity var(--md-sys-motion-duration-short), transform var(--md-sys-motion-duration-short);
}
.md-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

}
@layer components {
/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--md-sys-on-surface-variant);
}
.empty-state .material-symbols-rounded {
    font-size: 48px;
    color: var(--md-sys-outline);
    margin-bottom: 12px;
    display: block;
    font-variation-settings: 'FILL' 0, 'wght' 300;
}
.empty-state p {
    font-size: 14px;
    font-weight: 500;
}

}
@layer utilities {
/* --- Hidden --- */
.hidden { display: none !important; }
.pip-video-source {
    position: fixed;
    width: 1px;
    height: 1px;
    right: 0;
    bottom: 0;
    opacity: 0.01;
    pointer-events: none;
}

}
@layer components {
/* --- Input Card --- */
.input-card .md-grid { margin: 8px 0 4px; }
.input-card { padding: 14px; }
.md-grid.strength-input-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.strength-input-grid .md-field {
    min-width: 0;
}
.strength-input-grid > .span-full,
.strength-input-grid .md-switch.span-full {
    grid-column: 1 / -1;
}
.md-grid.strength-input-grid .strength-name-field {
    grid-column: span 2;
}
.md-grid.strength-input-grid .strength-phase-field {
    grid-column: span 1;
}
.strength-input-grid .md-field label {
    max-width: calc(100% - 18px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.strength-input-grid .md-field input,
.strength-input-grid .md-field select {
    min-width: 0;
    padding-left: 9px;
    padding-right: 9px;
}
.strength-input-grid .md-field input:focus,
.strength-input-grid .md-field select:focus {
    padding-left: 8px;
    padding-right: 8px;
}
.strength-presets {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 10px 0 4px;
}
.strength-presets::-webkit-scrollbar {
    display: none;
}
.strength-presets .md-chip {
    flex: none;
    min-height: 36px;
    font-size: 12px;
    font-weight: 800;
}
.md-field-helper {
    display: block;
    margin: 4px 0 0 2px;
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    font-weight: 700;
}
.md-field input:disabled {
    opacity: .48;
}
.input-card-actions {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-top: 12px;
}
.set-review-rpe {
    display: grid;
    gap: 8px;
}
.set-review-rpe summary {
    color: var(--md-sys-on-surface-variant);
    font-size: 13px;
    font-weight: 800;
}
.set-review-rpe-options {
    display: flex;
    gap: 6px;
    margin: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.set-review-rpe-options::-webkit-scrollbar {
    display: none;
}
.set-review-rpe-label {
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
}
.set-review-rpe-btn {
    min-width: 84px;
    min-height: 44px;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 13px;
    font-weight: 800;
}
.set-review-rpe-btn.active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.set-review-rpe-btn span {
    font-size: 10px;
    font-weight: 700;
}
.input-card-actions .md-btn-filled {
    flex: 1;
    margin-top: 0;
    min-width: 0;
}
.input-card-lib-btn {
    flex: none;
    width: 48px;
    min-width: 48px;
    padding: 0;
    margin-top: 0;
    height: 48px;
}
@media (max-width: 480px) {
    .strength-input-grid { gap: 6px; }
    .strength-input-grid .md-field input,
    .strength-input-grid .md-field select {
        padding-left: 8px;
        padding-right: 8px;
        font-size: 15px;
    }
    .strength-input-grid .md-field label {
        left: 9px;
        font-size: 12px;
        max-width: calc(100% - 14px);
    }
    .strength-input-grid .md-field input:focus + label,
    .strength-input-grid .md-field input:not(:placeholder-shown) + label,
    .strength-input-grid .md-field select:focus + label,
    .strength-input-grid .md-field select:valid + label {
        font-size: 9.5px;
    }
}
@media (max-width: 360px) {
    .strength-input-grid { gap: 6px; }
    .strength-input-grid .md-field label { left: 8px; font-size: 11px; max-width: calc(100% - 12px); }
    .strength-input-grid .md-field input,
    .strength-input-grid .md-field select {
        padding-left: 7px;
        padding-right: 7px;
        font-size: 14px;
    }
    .strength-input-grid .md-field input:focus + label,
    .strength-input-grid .md-field input:not(:placeholder-shown) + label,
    .strength-input-grid .md-field select:focus + label,
    .strength-input-grid .md-field select:valid + label {
        font-size: 9px;
    }
    .input-card-actions { gap: 6px; }
    .input-card-lib-btn { width: 44px; min-width: 44px; height: 44px; }
    .input-card-actions .md-btn-filled { height: 44px; font-size: 14px; }
}


}
@layer components {
/* --- Theme Controls (Material You / Monet) --- */
.theme-panel {
    display: grid;
    gap: 10px;
}
.theme-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--md-sys-on-surface-variant);
    font-size: 13px;
    font-weight: 700;
}
.theme-panel-title .material-symbols-rounded {
    color: var(--md-sys-primary);
    font-size: 18px;
    font-variation-settings: 'FILL' 1;
}
.theme-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.theme-swatch {
    width: 30px;
    height: 30px;
    border: 2px solid transparent;
    border-radius: var(--md-sys-shape-full);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.theme-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.22);
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.theme-swatch:hover {
    box-shadow:
        0 3px 10px rgba(0,0,0,0.14),
        inset 0 0 0 1px rgba(0,0,0,0.12);
}
.theme-swatch:hover::after { opacity: 0.5; }
.theme-swatch.active,
.theme-swatch:active {
    border-color: var(--md-sys-on-surface);
    transform: scale(1.08);
}
.theme-swatch:active::after { opacity: 0.7; }
.theme-blue { background: #0061a4; }
.theme-purple { background: #6750a4; }
.theme-green { background: #1a5e1f; }
.theme-orange { background: #9a4600; }
.theme-rose { background: #ba005c; }
.theme-monet {
    width: 32px;
    height: 32px;
    padding: 0;
    flex: none;
    font-size: 12px;
    background: linear-gradient(120deg, var(--md-sys-secondary-container), var(--md-sys-tertiary-container));
}
.theme-monet .material-symbols-rounded { font-size: 18px; }
.theme-monet.active { outline: 2px solid var(--md-sys-primary); outline-offset: 2px; }
.color-picker {
    width: 32px;
    height: 32px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container-highest);
    color: var(--md-sys-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    position: relative;
}
.color-picker input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.color-picker .material-symbols-rounded { font-size: 18px; }
.compact-divider { margin: 8px 0; }
.theme-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1 1 0;
    min-width: 0;
    padding: 0 12px;
    height: 36px;
    line-height: 1;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
}
.theme-mode-btn .material-symbols-rounded { font-size: 18px; flex: none; }
.theme-actions:has(.theme-mode-btn) { flex-wrap: nowrap; }

/* --- Theme Presets (6 color seeds) --- */
[data-theme="purple"] {
    --md-sys-primary: #7B4F9D;
    --md-sys-primary-container: #f2daff;
    --md-sys-on-primary-container: #2c0d44;
    --md-sys-tertiary-container: #ffd9e2;
    --md-sys-on-tertiary-container: #3e001e;
    --md-sys-secondary-container: #e8def8;
    --md-sys-on-secondary-container: #1d192b;
}
[data-theme="green"] {
    --md-sys-primary: #386a20;
    --md-sys-primary-container: #b7f397;
    --md-sys-on-primary-container: #072100;
    --md-sys-tertiary-container: #bcebe7;
    --md-sys-on-tertiary-container: #00201e;
    --md-sys-secondary-container: #dae5d2;
    --md-sys-on-secondary-container: #101f0d;
}
[data-theme="amber"] {
    --md-sys-primary: #a4570d;
    --md-sys-primary-container: #ffdcbe;
    --md-sys-on-primary-container: #341100;
    --md-sys-tertiary-container: #fff0c4;
    --md-sys-on-tertiary-container: #291800;
    --md-sys-secondary-container: #f7dec5;
    --md-sys-on-secondary-container: #271904;
}
[data-theme="rose"] {
    --md-sys-primary: #b71c5c;
    --md-sys-primary-container: #ffd9e2;
    --md-sys-on-primary-container: #3f0019;
    --md-sys-tertiary-container: #ffdbcd;
    --md-sys-on-tertiary-container: #3a0a00;
    --md-sys-secondary-container: #f4dde0;
    --md-sys-on-secondary-container: #22171a;
}
[data-theme="teal"] {
    --md-sys-primary: #006a6a;
    --md-sys-primary-container: #9cf1f0;
    --md-sys-on-primary-container: #002020;
    --md-sys-tertiary-container: #c2e7ff;
    --md-sys-on-tertiary-container: #001e30;
    --md-sys-secondary-container: #cce8e7;
    --md-sys-on-secondary-container: #051f1f;
}

}
@layer components {
/* --- Modal --- */
.md-modal {
    position: fixed;
    inset: 0;
    z-index: 220;
    display: grid;
    place-items: center;
}
.md-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 18, 28, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.md-modal-card {
    position: relative;
    z-index: 1;
    width: min(92vw, 420px);
    max-height: min(88vh, 720px);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 16px;
    border-radius: var(--md-sys-shape-xl);
    background: var(--md-sys-surface-container-lowest);
    box-shadow: var(--md-sys-elevation-3);
    display: grid;
    gap: 12px;
}
.md-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.md-modal-head strong { font-size: 18px; }
.modal-grid { margin: 0; }
.modal-actions {
    flex-wrap: nowrap;
    margin-top: 0;
}
.modal-actions .md-btn {
    flex: 1;
    min-width: 0;
    width: auto;
    height: 46px;
    margin-top: 0;
    padding-inline: 14px;
}
.md-modal-sheet {
    align-items: end;
    place-items: end center;
}
.md-modal-sheet-card {
    width: min(100vw, 520px);
    max-height: min(86vh, 760px);
    border-radius: 28px 28px 0 0;
    padding-top: 24px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateY(var(--sheet-drag-y, 0));
    transition: transform var(--md-sys-motion-duration-medium2, 300ms) var(--md-expressive-spring);
}
.md-modal-sheet-card::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: var(--md-sys-outline-variant);
    transform: translateX(-50%);
}
.md-modal-sheet-card.is-dragging {
    transition: none;
}

.template-manager-body {
    display: grid;
    gap: 12px;
}

.template-manager-list {
    display: grid;
    gap: 8px;
}

.template-manager-item {
    width: 100%;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.template-manager-item.active {
    border-color: var(--md-sys-primary);
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}

.template-manager-item-main {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.template-manager-item-main strong,
.template-manager-item-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-manager-item-actions {
    display: inline-flex;
    gap: 8px;
    flex: none;
}

.template-manager-item-actions .material-symbols-rounded {
    font-size: 20px;
    cursor: pointer;
}

.template-manager-toolbar {
    display: flex;
    justify-content: flex-end;
}

.template-editor-card {
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    padding: 12px;
    background: var(--md-sys-surface-container-lowest);
    display: grid;
    gap: 12px;
}

.template-editor-card textarea {
    width: 100%;
    resize: vertical;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    padding-top: 18px;
    outline: none;
}

/* --- AI Usage Dialog --- */
.ai-usage-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.ai-usage-period {
    padding: 12px 8px;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-low);
    border: 1px solid var(--md-sys-outline-variant);
    display: grid;
    gap: 6px;
    text-align: center;
}
.ai-usage-period:first-child {
    background: color-mix(in srgb, var(--md-sys-primary-container) 40%, var(--md-sys-surface-container-low));
    border-color: color-mix(in srgb, var(--md-sys-primary) 20%, transparent);
}
.ai-usage-period-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--md-sys-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ai-usage-metric {
    display: grid;
    gap: 1px;
}
.ai-usage-metric b {
    font-size: 20px;
    line-height: 1.1;
    color: var(--md-sys-on-surface);
}
.ai-usage-metric small {
    font-size: 10px;
    color: var(--md-sys-on-surface-variant);
    font-weight: 600;
}
.ai-usage-cost {
    font-size: 12px;
    font-weight: 700;
    color: var(--md-sys-primary);
}
.ai-usage-detail {
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
    border: 1px solid var(--md-sys-outline-variant);
    display: grid;
    gap: 6px;
}
.ai-usage-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--md-sys-on-surface-variant);
}
.ai-usage-detail-row span:last-child {
    font-weight: 700;
    color: var(--md-sys-on-surface);
    font-variant-numeric: tabular-nums;
}


}
@layer components {
/* ============================================
   Record Page — Refactored Layout
   ============================================ */

/* Record Overview Card (compact) */
.record-overview-card { display: grid; gap: 14px; }
.record-overview-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}
.record-overview-date h3 {
    font-size: 26px;
    line-height: 1.08;
    color: var(--md-sys-on-surface);
    letter-spacing: -0.4px;
    margin-top: 2px;
}
.record-overview-date p {
    margin-top: 4px;
    color: var(--md-sys-on-surface-variant);
    font-size: 13px;
}
.record-overview-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.record-overview-stat {
    padding: 10px 8px;
    border-radius: var(--md-sys-shape-md);
    background: color-mix(in srgb, var(--md-sys-surface-container-lowest) 86%, transparent);
    display: grid;
    gap: 2px;
    text-align: center;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 70%, transparent);
}
.record-overview-stat b { font-size: 18px; color: var(--md-sys-primary); font-variant-numeric: tabular-nums; }
.record-overview-stat small { color: var(--md-sys-on-surface-variant); font-size: 11px; }

/* Quick Actions */
.record-quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 0 16px 4px;
}
.record-quick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 4px;
    min-height: 64px;
    border: none;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    -webkit-tap-highlight-color: transparent;
    box-shadow: var(--md-sys-elevation-1);
    border: 1px solid var(--md-sys-outline-variant);
}
.record-quick-btn .material-symbols-rounded {
    font-size: 22px;
    color: var(--md-sys-primary);
    font-variation-settings: 'FILL' 1;
}
.record-quick-btn:active {
    transform: scale(0.95);
    background: var(--md-sys-surface-container);
}
.record-quick-btn-ai {
    background: color-mix(in srgb, var(--md-sys-primary-container) 40%, var(--md-sys-surface-container-low));
    border-color: color-mix(in srgb, var(--md-sys-primary) 25%, var(--md-sys-outline-variant));
}
.record-quick-btn-ai .material-symbols-rounded {
    color: var(--md-sys-primary);
}

/* Scrollable Record Tabs (5 tabs) */
.record-tabs-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding: 4px 12px;
    margin: 8px 4px;
}
.record-tabs-scroll::-webkit-scrollbar { display: none; }
.record-tabs-scroll .record-tab {
    flex: 1;
    min-width: 0;
    padding: 0 8px;
    white-space: nowrap;
    font-size: 12px;
}
.health-swipe-deck {
    display: flex;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    padding: 0;
}
.health-swipe-deck::-webkit-scrollbar { display: none; }
.health-swipe-page {
    flex: 0 0 100%;
    min-width: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    transform-origin: center top;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized-decelerate),
        opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    will-change: transform, opacity;
    padding-bottom: 4px;
}
.health-swipe-page > .md-card:first-child { margin-top: 4px; }

/* Today Timeline */
.today-timeline-card { display: grid; gap: 0; padding: 14px; }
.today-timeline-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.today-timeline-header .material-symbols-rounded {
    font-size: 20px;
    color: var(--md-sys-primary);
    font-variation-settings: 'FILL' 1;
}
.today-timeline-header strong { flex: 1; font-size: 14px; }
.today-timeline-header small { color: var(--md-sys-on-surface-variant); font-size: 12px; }
.today-timeline-list {
    display: grid;
    gap: 0;
    position: relative;
}
.today-timeline-list::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--md-sys-outline-variant);
    border-radius: 1px;
}
.today-timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    position: relative;
}
.today-timeline-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-variation-settings: 'FILL' 1;
    flex: none;
    position: relative;
    z-index: 1;
}
.today-timeline-diet .today-timeline-icon {
    background: color-mix(in srgb, #059669 20%, var(--md-sys-surface-container-lowest));
    color: #059669;
}
.today-timeline-training .today-timeline-icon {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}
.today-timeline-exercise .today-timeline-icon {
    background: color-mix(in srgb, #8b5cf6 20%, var(--md-sys-surface-container-lowest));
    color: #8b5cf6;
}
.today-timeline-weight .today-timeline-icon {
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
}
.today-timeline-body {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 2px;
    padding-top: 2px;
}
.today-timeline-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.today-timeline-main strong {
    font-size: 13px;
    color: var(--md-sys-on-surface);
}
.today-timeline-main span {
    font-size: 13px;
    color: var(--md-sys-on-surface-variant);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.today-timeline-body small {
    font-size: 11px;
    color: var(--md-sys-outline);
    font-weight: 600;
}
.today-timeline-empty {
    text-align: center;
}

/* Context AI Card */
.context-ai-card {
    display: grid;
    align-content: start;
    gap: 14px;
    min-height: 148px;
    padding: 16px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--md-sys-surface-container-lowest) 78%, transparent), var(--md-sys-surface-container-low));
    border-color: color-mix(in srgb, var(--md-sys-tertiary) 18%, var(--md-sys-outline-variant));
}
.context-ai-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.context-ai-head h3 {
    font-size: 16px;
    color: var(--md-sys-on-surface);
    line-height: 1.25;
}
.context-ai-head small {
    display: block;
    margin-top: 4px;
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    line-height: 1.45;
}
.context-ai-icon {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-size: 24px;
    font-variation-settings: 'FILL' 1;
    flex: none;
}
.context-ai-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: auto;
}
.context-ai-btn {
    min-width: 0;
    height: 40px;
    font-size: 12px;
    padding: 0 12px;
    white-space: nowrap;
}

/* Recent History List */
.recent-history-list {
    display: grid;
    gap: 4px;
}

/* Sheet-style Modal (bottom slide-up) */
.md-modal-sheet {
    align-items: flex-end;
}
.md-modal-sheet-card {
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--md-sys-shape-xl) var(--md-sys-shape-xl) 0 0;
    overflow-y: auto;
    animation: sheetSlideUp 300ms var(--md-sys-motion-emphasized-decelerate);
}
@keyframes sheetSlideUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
}
.diet-modal-body,
.exercise-modal-body {
    display: grid;
    gap: 12px;
    padding: 0 0 16px;
}
.diet-modal-body .diet-meal-selector,
.diet-modal-body .diet-mode-tabs {
    margin: 0;
}
.diet-modal-body .diet-ai-entry {
    margin: 0;
}
.diet-modal-body .food-search-results {
    max-height: 200px;
}

.today-timeline-sub {
    font-size: 11px;
    color: var(--md-sys-outline);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pr-board-card,
.volume-heatmap-card {
    display: grid;
    gap: 10px;
}

.pr-board-list {
    display: grid;
    gap: 8px;
}

.pr-board-item.collapsed .pr-board-history {
    display: none;
}

.volume-heatmap-svg {
    width: 100%;
    height: auto;
    display: block;
}

.volume-heatmap-label {
    font-size: 9px;
    fill: var(--md-sys-on-surface-variant);
}

.volume-heatmap-cell {
    cursor: pointer;
    transition: transform .12s ease, opacity .12s ease;
}

.volume-heatmap-cell:hover,
.volume-heatmap-cell:active {
    transform: scale(1.06);
    opacity: 0.92;
}


/* TASK-22: Today-timeline item swipe-open (M3 Expressive) */
.today-timeline-item {
    transition: transform .28s var(--md-expressive-spring);
    touch-action: pan-y;
}
.today-timeline-item.swipe-open .delete-btn {
    background: var(--md-sys-error, #b3261e); color: #fff;
}
}
@layer components {
/* ============================================
   Workout Plan Card & Library Sheet
   ============================================ */

/* Workout Plan Card */
.workout-plan-card { display: grid; gap: 12px; overflow: hidden; }
.workout-plan-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}
.workout-plan-toolbar::-webkit-scrollbar { display: none; }
.workout-plan-toolbar .md-btn {
    min-height: 40px;
    margin-top: 0;
    white-space: nowrap;
    flex: none;
}
.workout-plan-toolbar .icon-btn {
    flex: none;
}
.workout-plan-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.workout-plan-info {
    flex: 1;
    min-width: 0;
}
.workout-plan-info h3 {
    font-size: 18px;
    line-height: 1.2;
    color: var(--md-sys-on-surface);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workout-plan-info small {
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workout-plan-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    font-size: 22px;
    font-variation-settings: 'FILL' 1;
    flex: none;
}
.workout-plan-actions-top {
    display: flex;
    gap: 4px;
    flex: none;
}

/* Empty State */
.workout-plan-empty {
    text-align: center;
    padding: 20px 16px;
}
.workout-plan-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    font-size: 28px;
    margin-bottom: 12px;
}
.workout-plan-empty-text strong {
    display: block;
    font-size: 16px;
    color: var(--md-sys-on-surface);
    margin-bottom: 4px;
}
.workout-plan-empty-text p {
    font-size: 13px;
    color: var(--md-sys-on-surface-variant);
    line-height: 1.45;
    margin-bottom: 16px;
}
.workout-plan-empty-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Import Prompt */
.workout-plan-import-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.workout-plan-import-head > div:first-child {
    flex: 1;
    min-width: 0;
}
.workout-plan-import-head h3 {
    font-size: 16px;
    line-height: 1.2;
    color: var(--md-sys-on-surface);
}
.workout-plan-import-head small {
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
}

/* Recent Plans List */
.workout-plan-recent {
    display: grid;
    gap: 4px;
}
.workout-plan-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
    cursor: pointer;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 50%, transparent);
}
.workout-plan-recent-item:active {
    transform: scale(0.98);
    background: var(--md-sys-surface-container);
}
.workout-plan-recent-item .material-symbols-rounded {
    font-size: 20px;
    color: var(--md-sys-primary);
    flex: none;
}
.workout-plan-recent-info {
    flex: 1;
    min-width: 0;
}
.workout-plan-recent-info strong {
    display: block;
    font-size: 14px;
    color: var(--md-sys-on-surface);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workout-plan-recent-info small {
    font-size: 12px;
    color: var(--md-sys-on-surface-variant);
}

/* Quick Switch Chips */
.workout-plan-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 4px;
    min-width: 0;
    overflow: hidden;
}
.workout-plan-switch small {
    font-size: 11px;
    color: var(--md-sys-on-surface-variant);
    font-weight: 600;
    white-space: nowrap;
    flex: none;
}
.workout-plan-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
    padding: 2px 0;
}
.workout-plan-chips::-webkit-scrollbar { display: none; }
.workout-plan-chip {
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 28px;
    padding: 0 10px;
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    flex: none;
    max-width: 140px;
    overflow: hidden;
}
.workout-plan-chip .material-symbols-rounded { font-size: 14px; flex: none; }
.workout-plan-chip { text-overflow: ellipsis; }
.workout-plan-chip:active { transform: scale(0.95); }

/* View All Button */
.workout-plan-lib-btn {
    justify-self: center;
    margin-top: 4px;
}

/* Workout Library Sheet */
.workout-lib-list {
    display: grid;
    gap: 4px;
    max-height: 50vh;
    overflow-y: auto;
}
.workout-lib-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-lowest);
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 50%, transparent);
}
.workout-lib-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.workout-lib-item-main:active {
    opacity: 0.8;
}
.workout-lib-item-main .material-symbols-rounded {
    font-size: 20px;
    color: var(--md-sys-primary);
    flex: none;
}
.workout-lib-item-info {
    flex: 1;
    min-width: 0;
}
.workout-lib-item-info strong {
    display: block;
    font-size: 14px;
    color: var(--md-sys-on-surface);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.workout-lib-item-info small {
    font-size: 12px;
    color: var(--md-sys-on-surface-variant);
}
.workout-lib-item-actions {
    flex: none;
}

}
@layer components {
/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
    .md-card { margin: 4px 8px; padding: 12px; }
    .input-card { padding: 10px; }
    .record-quick-actions { gap: 4px; margin: 0 8px 2px; }
    .record-quick-btn { padding: 8px 2px; font-size: 10px; }
    .record-quick-btn .material-symbols-rounded { font-size: 20px; }
    .record-tabs-scroll { margin: 4px 2px; padding: 3px 8px; }
    .record-tabs-scroll .record-tab { padding: 0 10px; font-size: 11px; }
    #profile .record-tabs {
        gap: 4px;
        margin: 6px 8px;
        padding: 3px;
    }
    #profile .record-tab {
        gap: 3px;
        min-height: 34px;
        padding: 0 4px;
        font-size: 11px;
        white-space: nowrap;
    }
    #profile .record-tab .material-symbols-rounded {
        font-size: 16px;
    }
    .record-section-title { margin: 8px 12px 4px; }
    .record-overview-card { gap: 10px; }
    .record-overview-stats { gap: 6px; }
    .record-overview-stat { padding: 8px 4px; }
    .record-overview-stat b { font-size: 16px; }
    .today-timeline-card { padding: 10px; }
    .today-timeline-header { margin-bottom: 8px; }
    .today-timeline-item { padding: 6px 0; gap: 10px; }
    .calendar-card { padding: 10px; }
    .calendar-toolbar { margin-bottom: 6px; }
    .calendar-day { min-height: 54px; max-height: 54px; padding: 4px 3px; }
    .calendar-events { gap: 1px; margin-top: 2px; }
    .calendar-event {
        padding: 0 2px;
        font-size: clamp(8.5px, 2.4vw, 10px);
        line-height: 1;
    }
    .calendar-event .material-symbols-rounded {
        font-size: 10px;
        line-height: 1;
    }
    .calendar-day-head {
        min-height: 14px;
        max-height: 14px;
        font-size: 10px;
    }
    .calendar-day-head b { font-size: 8.5px; }
    .calendar-event-more {
        padding: 0 4px;
        font-size: 9px;
        line-height: 1;
    }
    .calendar-legend { padding-top: 8px; margin-top: 8px; gap: 6px; }
    .hero-stat-row { margin-top: 10px; gap: 6px; }
    .hero-stat { padding: 8px 6px; }
    .collapsible-card .collapse-content { gap: 6px; margin-top: 6px; }
    .diet-card { gap: 10px; }
    .weight-card { gap: 10px; }
    .context-ai-card { gap: 8px; }
    .context-ai-actions { grid-template-columns: 1fr; }
    .today-focus-card { gap: 10px; }
    .today-focus-hint { padding: 8px 10px; }
    .daily-summary-card { gap: 6px; }
    .daily-stat { padding: 8px 2px; }
    .macro-summary { gap: 6px; }
    .timer-stats b { font-size: 14px; }
    .list-item { margin: 4px 8px; padding: 8px 10px; }
    .workout-plan-card { gap: 8px; }
    .workout-plan-info h3 { font-size: 15px; }
    .workout-plan-icon { width: 36px; height: 36px; font-size: 18px; border-radius: 12px; }
    .workout-plan-recent-item { padding: 8px 10px; gap: 8px; }
    .workout-plan-chip { max-width: 110px; min-height: 26px; padding: 0 8px; font-size: 10px; }
    .workout-plan-empty { padding: 16px 12px; }
    .workout-plan-empty-actions { flex-direction: column; align-items: stretch; }
    .workout-plan-empty-actions .md-btn { width: 100%; }
}
@media (max-width: 360px) {
    .md-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .strength-input-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .md-card { margin: 3px 6px; padding: 10px; }
    .record-quick-actions { gap: 3px; margin: 0 6px 2px; }
    .record-quick-btn { padding: 6px 1px; font-size: 9px; }
    .record-quick-btn .material-symbols-rounded { font-size: 18px; }
    #profile .record-tab {
        gap: 2px;
        padding: 0 2px;
        font-size: 10px;
    }
    #profile .record-tab .material-symbols-rounded {
        font-size: 14px;
    }
    .ai-template-actions .md-btn {
        padding: 0 8px;
        font-size: 12px;
        gap: 4px;
    }
    .ai-template-actions .material-symbols-rounded {
        font-size: 16px;
    }
    .calendar-day { min-height: 48px; max-height: 48px; font-size: 10px; }
    .calendar-event {
        min-height: 10px;
        padding: 0 1px;
        border-left-width: 2px;
        font-size: 8px;
        line-height: 1;
        gap: 1px;
    }
    .calendar-event .material-symbols-rounded {
        display: inline-block;
        font-size: 9px;
        line-height: 1;
    }
    .calendar-event-more {
        min-height: 10px;
        padding: 0 2px;
        font-size: 8px;
        line-height: 1;
        color: var(--md-sys-on-surface-variant);
    }
    .advice-bubble.assistant { max-width: 100%; }
    .advice-bubble-content { font-size: 13.5px; line-height: 1.64; }
}
@media (min-width: 600px) {
    .md-grid { grid-template-columns: repeat(3, 1fr); }
    #app { max-width: none; margin: 0; }
    .md-nav-rail { max-width: none; left: auto; transform: none; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}


}
@layer components {
/* ============================================
   Dark Mode (M3 Expressive)
   Single source of truth for [data-theme-mode="dark"]
   and prefers-color-scheme: dark token overrides.
   Module-level dark adjustments may live alongside their
   host file ONLY for selectors that already need other
   dark-only properties (e.g. .hero gradient swap).
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --md-sys-primary: #a0cafd;
        --md-sys-on-primary: #003258;
        --md-sys-primary-container: #00497d;
        --md-sys-on-primary-container: #d1e4ff;

        --md-sys-secondary: #bbc7db;
        --md-sys-on-secondary: #253141;
        --md-sys-secondary-container: #3b4858;
        --md-sys-on-secondary-container: #d7e3f8;

        --md-sys-tertiary: #d6bee4;
        --md-sys-on-tertiary: #3b2948;
        --md-sys-tertiary-container: #523f5f;
        --md-sys-on-tertiary-container: #f2daff;

        --md-sys-amber: #fbbf24;
        --md-sys-amber-container: #78350f;

        --md-sys-surface: #111418;
        --md-sys-surface-dim: #111418;
        --md-sys-surface-container-lowest: #0b0e12;
        --md-sys-surface-container-low: #1a1c20;
        --md-sys-surface-container: #1e2024;
        --md-sys-surface-container-high: #282a2f;
        --md-sys-surface-container-highest: #33353a;
        --md-sys-on-surface: #e3e2e6;
        --md-sys-on-surface-variant: #c3c7cf;
        --md-sys-inverse-surface: #e1e4db;
        --md-sys-inverse-on-surface: #30322e;

        --md-sys-outline: #8d9199;
        --md-sys-outline-variant: #43474e;
        --timer-gradient-start: #001d36;
        --timer-gradient-mid: #00497d;
        --timer-gradient-end: #0061a4;
        --timer-time-color: #d1e4ff;
        --timer-orb: rgba(209, 228, 255, 0.12);

        --md-sys-error: #ffb4ab;
        --md-sys-error-container: #93000a;
        --md-sys-on-error-container: #ffdad6;

        /* V6 glass tokens — dark variant */
        --glass-bg: color-mix(in srgb, var(--md-sys-surface-container-high) 62%, transparent);
        --glass-bg-strong: color-mix(in srgb, var(--md-sys-surface-container-highest) 78%, transparent);
        --glass-border: color-mix(in srgb, var(--md-sys-on-surface) 14%, transparent);
        --glass-shadow-inset: inset 0 1px 0 color-mix(in srgb, var(--md-sys-on-surface) 8%, transparent);
        --glass-shadow-out: 0 2px 14px rgba(0,0,0,0.42);
    }

    body { background: var(--md-sys-surface); }
    .md-top-app-bar { background: transparent; }
    .md-nav-rail { background: var(--md-sys-surface-container); backdrop-filter: blur(20px); }

    .timer-panel {
        background: linear-gradient(145deg, var(--timer-gradient-start), var(--timer-gradient-mid) 42%, var(--timer-gradient-end) 100%);
    }
    #mainTime { color: var(--timer-time-color); text-shadow: 0 2px 20px rgba(160, 202, 253, 0.26); }
    .session-time { color: #fbbf24 !important; text-shadow: 0 0 12px rgba(251,191,36,0.25) !important; }

    .md-field input,
    .md-field select {
        background: var(--md-sys-surface-container-high);
        border-color: var(--md-sys-outline-variant);
        color: var(--md-sys-on-surface);
    }
    .md-field input:focus,
    .md-field select:focus { border-color: var(--md-sys-primary); }
    .md-field input:focus + label,
    .md-field input:not(:placeholder-shown) + label,
    .md-field select:focus + label { color: var(--md-sys-primary); }

    .list-item {
        background: var(--md-sys-surface-container-high);
        border-color: var(--md-sys-outline-variant);
    }
    .list-item:active { background: var(--md-sys-surface-container-highest); }
    .calendar-card {
        background:
            linear-gradient(180deg, rgba(51,53,58,0.62), rgba(30,32,36,0.22)),
            var(--md-sys-surface-container-low);
    }
    .calendar-day { background: var(--md-sys-surface-container-high); }
    .calendar-day.empty { background: transparent; }
    .calendar-day.has-record {
        background: color-mix(in srgb, var(--md-sys-primary-container) 28%, var(--md-sys-surface-container-high));
    }
    .calendar-day.selected {
        background: color-mix(in srgb, var(--md-sys-primary-container) 25%, var(--md-sys-surface-container-high));
        box-shadow: 0 0 0 2px var(--md-sys-primary);
    }
    .calendar-event {
        background: color-mix(in srgb, var(--event-color) 18%, var(--md-sys-surface-container-highest));
        color: color-mix(in srgb, var(--event-color) 35%, var(--md-sys-on-surface));
    }

    .md-btn-tonal {
        background: var(--md-sys-secondary-container);
        color: var(--md-sys-on-secondary-container);
    }
    .md-card {
        background: var(--md-sys-surface-container-low);
        border-color: var(--md-sys-outline-variant);
    }
    .workout-controls {
        background: rgba(30, 32, 36, 0.78);
        background:
            linear-gradient(135deg, rgba(51,53,58,0.74), rgba(30,32,36,0.44)),
            color-mix(in srgb, var(--md-sys-primary-container) 14%, transparent);
        box-shadow:
            0 16px 40px rgba(0, 0, 0, 0.42),
            0 4px 14px rgba(0, 0, 0, 0.28);
    }
    .food-result-item { background: var(--md-sys-surface-container-high); }
    .food-result-item:active { background: var(--md-sys-surface-container-highest); }
    .diet-log-item { background: var(--md-sys-surface-container-high); }
    .weightloss-option { border-color: var(--md-sys-outline-variant); }
    .weightloss-option.active { border-color: var(--md-sys-primary); background: color-mix(in srgb, var(--md-sys-primary-container) 18%, var(--md-sys-surface-container-high)); }
    .weightloss-tips { background: var(--md-sys-surface-container-high); }
    .nav-indicator { background: var(--md-sys-secondary-container); }
    .nav-item.active .material-symbols-rounded { color: var(--md-sys-on-secondary-container); }

    .advice-model-openai { --advice-model-bg: linear-gradient(135deg, #022c22, #064e3b); --advice-model-color: #a7f3d0; --advice-model-mark-bg: rgba(167, 243, 208, 0.14); }
    .advice-model-gemini { --advice-model-bg: linear-gradient(135deg, #121b4b, #1d2563); --advice-model-color: #c7d2fe; --advice-model-mark-bg: rgba(199, 210, 254, 0.14); }
    .advice-model-grok { --advice-model-bg: linear-gradient(135deg, #0b1120, #1f2937); --advice-model-color: #f8fafc; --advice-model-mark-bg: rgba(248, 250, 252, 0.12); }
    .advice-model-deepseek { --advice-model-bg: linear-gradient(135deg, #0b172d, #1e3a8a); --advice-model-color: #bfdbfe; --advice-model-mark-bg: rgba(191, 213, 254, 0.14); }
    .advice-model-claude { --advice-model-bg: linear-gradient(135deg, #2a1800, #3b2200); --advice-model-color: #fde68a; --advice-model-mark-bg: rgba(253, 230, 138, 0.12); }
    .advice-model-qwen { --advice-model-bg: linear-gradient(135deg, #121146, #161a5b); --advice-model-color: #d6f4fb; --advice-model-mark-bg: rgba(214, 244, 251, 0.14); }
    .advice-model-doubao { --advice-model-bg: linear-gradient(135deg, #2b0f0f, #3b1a0a); --advice-model-color: #fed7aa; --advice-model-mark-bg: rgba(254, 215, 170, 0.12); }
    .advice-model-kimi { --advice-model-bg: linear-gradient(135deg, #0b1437, #122266); --advice-model-color: #e0eaff; --advice-model-mark-bg: rgba(224, 234, 255, 0.12); }
    .advice-model-minimax { --advice-model-bg: linear-gradient(135deg, #052e27, #073f2f); --advice-model-color: #ccfbf1; --advice-model-mark-bg: rgba(204, 251, 241, 0.14); }
    .advice-model-mimo { --advice-model-bg: linear-gradient(135deg, #230b23, #2c0e2e); --advice-model-color: #f5d0fe; --advice-model-mark-bg: rgba(245, 208, 254, 0.14); }
    .advice-model-glm { --advice-model-bg: linear-gradient(135deg, #101445, #161b63); --advice-model-color: #c7d2fe; --advice-model-mark-bg: rgba(199, 210, 254, 0.14); }
    .advice-model-generic { --advice-model-bg: linear-gradient(135deg, var(--md-sys-secondary-container), var(--md-sys-tertiary-container)); --advice-model-color: var(--md-sys-on-secondary-container); --advice-model-mark-bg: var(--md-sys-surface-container-highest); }
    .advice-model-mark {
        background: var(--advice-model-mark-bg, color-mix(in srgb, var(--md-sys-surface-container-highest) 60%, transparent));
    }
}

/* Explicit dark theme override (matches the @media block above). */
[data-theme-mode="dark"] {
    --glass-bg: color-mix(in srgb, var(--md-sys-surface-container-high) 62%, transparent);
    --glass-bg-strong: color-mix(in srgb, var(--md-sys-surface-container-highest) 78%, transparent);
    --glass-border: color-mix(in srgb, var(--md-sys-on-surface) 14%, transparent);
    --glass-shadow-inset: inset 0 1px 0 color-mix(in srgb, var(--md-sys-on-surface) 8%, transparent);
    --glass-shadow-out: 0 2px 14px rgba(0,0,0,0.42);
}

}
@layer components {
/* --- Identity Card --- */
#profileContent {
    touch-action: pan-y;
    transform: translateX(var(--profile-swipe-x, 0));
    transition: transform 0.28s var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1));
    will-change: transform;
}
#profileContent.profile-view-dragging {
    transition: none;
}
.profile-tabs {
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-outline-variant) 55%, transparent);
}
.profile-tabs .record-tab {
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    transition:
        color var(--md-sys-motion-duration-medium, 300ms) var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1)),
        transform var(--md-sys-motion-duration-short, 180ms) var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1)),
        background-color var(--md-sys-motion-duration-medium, 300ms) ease;
}
.profile-tabs .record-tab::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: var(--md-sys-shape-full);
    background: color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
    opacity: 0;
    transform: scaleX(0.55) scaleY(0.86);
    transition:
        opacity var(--md-sys-motion-duration-medium, 300ms) ease,
        transform 0.42s var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1));
    pointer-events: none;
}
.profile-tabs .record-tab.active {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
}
.profile-tabs .record-tab.active::after {
    opacity: 1;
    transform: scaleX(1) scaleY(1);
}
.profile-tabs .record-tab .material-symbols-rounded {
    position: relative;
    z-index: 1;
    transition: transform 0.34s var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1));
}
.profile-tabs .record-tab.active .material-symbols-rounded {
    transform: scale(1.08) rotate(-4deg);
    font-variation-settings: 'FILL' 1;
}
.profile-tabs .record-tab:active {
    transform: scale(0.96);
}
.profile-tabs .record-tab span,
.profile-tabs .record-tab {
    z-index: 1;
}
.profile-tab-label {
    position: relative;
    z-index: 1;
}
.profile-view-forward,
.profile-view-back {
    animation: profile-tab-slide 0.34s var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1)) both;
}
.profile-view-back {
    animation-name: profile-tab-slide-back;
}
@keyframes profile-tab-slide {
    from { opacity: 0.72; transform: translateX(18px) scale(0.985); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes profile-tab-slide-back {
    from { opacity: 0.72; transform: translateX(-18px) scale(0.985); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
.identity-card {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.identity-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.identity-icon {
    font-size: 28px;
    padding: 10px;
    border-radius: 50%;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}
.identity-text strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--md-sys-on-surface);
}
.identity-text small {
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
}
.identity-text {
    flex: 1;
    min-width: 0;
}
.identity-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.identity-metric {
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-md, 12px);
    background: var(--md-sys-surface-container-lowest);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.identity-metric-head {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--md-sys-on-surface-variant);
}
.identity-metric-head .material-symbols-rounded {
    font-size: 14px;
}
.identity-metric b {
    font-size: 18px;
    font-weight: 700;
    color: var(--md-sys-on-surface);
}
.identity-metric small {
    font-size: 11px;
    opacity: 0.75;
}
.identity-training-split {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 10px;
    color: var(--md-sys-on-surface-variant);
}
.identity-training-split span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    white-space: nowrap;
}
.identity-training-split strong {
    color: var(--md-sys-primary);
    font-size: 10px;
}
.identity-bar {
    height: 5px;
    border-radius: 3px;
    margin-top: 4px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
}
.identity-bar i {
    display: block;
    height: 100%;
    background: var(--md-sys-primary);
    transition: width 0.4s ease;
}
.identity-metric.weight-positive .identity-bar i { background: #2e7d32; }
.identity-metric.weight-positive b { color: #2e7d32; }
.identity-metric.weight-negative .identity-bar i { background: #c62828; }
.identity-metric.weight-negative b { color: #c62828; }
.identity-metric.weight-neutral .identity-bar i { background: var(--md-sys-outline); }
.identity-action {
    flex: none;
    align-self: center;
    min-width: max-content;
    padding: 0 14px;
    white-space: nowrap;
}
@media (max-width: 360px) {
    .identity-card {
        gap: 10px;
    }
    .identity-row {
        gap: 8px;
    }
    .identity-icon {
        font-size: 24px;
        padding: 8px;
    }
    .identity-text strong {
        font-size: 14px;
    }
    .identity-action {
        height: 36px;
        padding: 0 10px;
        font-size: 12px;
        gap: 4px;
    }
    .identity-action .material-symbols-rounded {
        font-size: 16px;
    }
    .identity-metrics {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 6px;
    }
    .identity-metric {
        padding: 8px;
    }
    .identity-metric b {
        font-size: 15px;
    }
}

}
@layer components {
/* --- Theme Sheet --- */
.theme-trigger {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    color: var(--md-sys-on-surface);
}
.theme-trigger:hover {
    background: var(--md-sys-surface-container);
}
.theme-trigger .theme-dot {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--md-sys-primary);
    border: 1.5px solid var(--md-sys-surface);
    pointer-events: none;
}
.theme-sheet-card {
    max-width: 480px;
}
.theme-sheet-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--md-sys-outline-variant, rgba(0,0,0,0.08));
}
.theme-sheet-section:last-child {
    border-bottom: none;
}
.theme-sheet-section .theme-panel-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--md-sys-on-surface-variant);
}
.theme-language-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: -0.4px;
    flex: none;
}
.theme-sheet-section .theme-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.theme-language-field select {
    padding-top: 16px;
    padding-bottom: 4px;
    padding-left: 12px;
}
.theme-language-field label {
    top: 5px;
    transform: translateY(0);
    font-size: 10px;
    color: var(--md-sys-primary);
    font-weight: 600;
}

}
@layer components {
/* --- Library Segment --- */
.library-segment-wrap {
    margin: 8px 12px 4px;
}
.library-segment {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-sys-outline-variant) 55%, transparent);
    overflow: hidden;
}
.library-segment-btn {
    position: relative;
    z-index: 1;
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 36px;
    padding: 0 8px;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    font-weight: 700;
    font-size: clamp(11px, 3.2vw, 13px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition:
        color var(--md-sys-motion-duration-medium, 300ms) ease,
        transform var(--md-sys-motion-duration-short, 180ms) var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1));
}
.library-segment-btn.active {
    color: var(--md-sys-on-primary-container);
}
.library-segment-btn .material-symbols-rounded {
    font-size: 18px;
    transition: transform .28s var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1));
}
.library-segment-btn.active .material-symbols-rounded {
    transform: scale(1.08);
    font-variation-settings: 'FILL' 1;
}
.library-segment-btn:active {
    transform: scale(.96);
}
.library-segment-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 2px);
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-primary-container);
    transition: transform .32s var(--md-expressive-spring, cubic-bezier(.34,1.56,.64,1));
    pointer-events: none;
}
.library-segment-indicator.is-routines {
    transform: translateX(calc(100% + 4px));
}
.library-swipe-deck {
    display: flex;
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    padding: 0;
}
.library-swipe-deck::-webkit-scrollbar {
    display: none;
}
.library-swipe-page {
    flex: 0 0 100%;
    min-width: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    transform-origin: center top;
    transition:
        transform var(--md-sys-motion-duration-medium, 300ms) var(--md-sys-motion-emphasized-decelerate, cubic-bezier(.2,0,0,1)),
        opacity var(--md-sys-motion-duration-short, 180ms) var(--md-sys-motion-emphasized, cubic-bezier(.2,0,0,1));
    will-change: transform, opacity;
    padding-bottom: 4px;
}
.library-list {
    display: grid;
    gap: 8px;
}
.library-card {
    margin: 0 8px;
}
.library-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
}
.library-inline-tags {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.library-inline-tags span {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.library-card-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.library-card-actions::-webkit-scrollbar { display: none; }
.library-card-actions .md-btn {
    flex: none;
    white-space: nowrap;
    padding: 0 10px;
    height: 32px;
    font-size: 12px;
    overflow: hidden;
}
.library-card-actions .md-btn .material-symbols-rounded {
    flex: none;
    font-size: 17px;
}
.library-card-actions .md-btn span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.library-tag-chips {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 8px 8px;
    padding-bottom: 2px;
}
.library-tag-chips::-webkit-scrollbar {
    display: none;
}
.library-tag-chips .md-btn {
    flex: none;
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
}

}
@layer components {
/* --- Advice / AI Coach --- */
#ai-coach.page {
    padding: 0 14px 0;
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
}
#ai-coach.page.active {
    display: block;
}
#ai-coach.page.active > #aiCoachContent {
    width: 100%;
    min-height: 0;
    display: block;
}
.advice-main-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 8px 12px 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
.advice-main-card:hover,
.advice-main-card:active {
    background-image: none;
    transform: none;
}
.advice-main-card.advice-no-enter {
    animation: none;
}
.advice-chat-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}
.advice-top-chrome {
    --advice-top-chrome-visible: var(--advice-top-chrome-full, auto);
    --advice-top-chrome-offset: 0px;

    flex: none;
    height: var(--advice-top-chrome-visible);
    margin-bottom: clamp(0px, var(--advice-top-chrome-visible, 0px), 12px);
    overflow: hidden;
    will-change: height;
}
.advice-top-chrome-inner {
    display: grid;
    gap: 8px;
    transform: translateY(var(--advice-top-chrome-offset));
    will-change: transform;
}
.advice-top-chrome.is-collapsed {
    pointer-events: none;
}
.advice-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.advice-chat-header h3 { font-size: 18px; line-height: 1.2; color: var(--md-sys-on-surface); }
.advice-chat-header small { color: var(--md-sys-on-surface-variant); }
.advice-chat-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-variation-settings: 'FILL' 1;
}
.advice-context-bar {
    display: grid;
    gap: 8px;
}

.advice-template-row {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.advice-template-row::-webkit-scrollbar { display: none; }

.advice-version-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px;
    border-radius: var(--md-sys-shape-full);
    background: color-mix(in srgb, var(--md-sys-surface-container-highest) 70%, transparent);
    color: var(--md-sys-on-surface-variant);
    margin-left: 4px;
}
.advice-version-switcher .advice-version-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.advice-version-switcher .advice-version-btn .material-symbols-rounded { font-size: 16px; }
.advice-version-switcher .advice-version-btn.active {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}
.advice-version-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--md-sys-on-surface-variant);
    min-width: 28px;
    text-align: center;
}

.advice-status-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.advice-status-text { flex: 1 1 auto; min-width: 0; }
.advice-stream-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--md-sys-shape-full);
    border: none;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .18s ease, transform .12s ease;
}
.advice-stream-toggle .material-symbols-rounded {
    font-size: 16px;
    font-variation-settings: 'FILL' 1;
}
.advice-stream-toggle.advice-stream-toggle-secondary {
    background: var(--md-sys-surface-container-highest);
    color: var(--md-sys-on-surface-variant);
}
.advice-stream-toggle:active { transform: scale(0.96); }
.advice-stream-toggle.hidden { display: none; }
.advice-filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}
.advice-search-toggle {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: none;
}
.advice-search-toggle.active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.advice-search-toggle:active {
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    transform: none;
}
.advice-search-toggle.active:active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.advice-search-toggle .material-symbols-rounded { font-size: 18px; }
.advice-search-row {
    min-height: 38px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
}
.advice-search-row .material-symbols-rounded { font-size: 18px; color: var(--md-sys-primary); }
.advice-search-row input {
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--md-sys-on-surface);
    font: inherit;
    font-size: 13px;
}
.advice-search-row input::placeholder { color: var(--md-sys-on-surface-variant); opacity: 0.72; }
.advice-search-row button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.advice-quick-prompts {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 2px;
    background: transparent;
    scrollbar-width: none;
    flex: none;
}
.advice-range-tabs,
.advice-context-toggles {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}
.advice-range-tabs::-webkit-scrollbar,
.advice-context-toggles::-webkit-scrollbar,
.advice-quick-prompts::-webkit-scrollbar { display: none; }
.advice-pill,
.advice-quick-prompts button {
    border: none;
    border-radius: var(--md-sys-shape-full);
    min-height: 32px;
    padding: 0 12px;
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: none;
}
.advice-pill.active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.advice-pill:active {
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    transform: none;
}
.advice-pill.active:active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.advice-filter-actions {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex: none;
}
.advice-search-toggle { position: relative; }
.advice-ctx-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-primary);
    color: var(--md-sys-on-primary);
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.advice-context-popover {
    background: var(--md-sys-surface-container);
    border-radius: 14px;
    padding: 10px 12px;
    display: grid;
    gap: 8px;
    animation: adviceCtxIn .18s ease;
}
@keyframes adviceCtxIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}
.advice-context-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--md-sys-on-surface-variant);
    font-weight: 700;
}
.advice-context-popover-head button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
    -webkit-tap-highlight-color: transparent;
}
.advice-context-popover-head button:hover {
    background: color-mix(in srgb, var(--md-sys-on-surface) 8%, transparent);
    color: var(--md-sys-on-surface);
}
.advice-context-popover-head button:active {
    background: color-mix(in srgb, var(--md-sys-on-surface) 14%, transparent);
    transform: scale(0.94);
}
.advice-context-popover-head button:focus-visible {
    outline: 2px solid var(--md-sys-primary);
    outline-offset: 2px;
}
.advice-context-popover-head .material-symbols-rounded {
    font-size: 20px;
    font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24;
    line-height: 1;
}
.advice-context-popover .advice-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.advice-context-popover .advice-pill .material-symbols-rounded { font-size: 14px; }
.advice-context-hint {
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    line-height: 1.4;
}
.routines-hero,
.daily-hero { margin-bottom: 10px; }
.routines-hero .hero-stat-row,
.daily-hero .hero-stat-row {
    margin-top: 12px;
}
.advice-chat-list {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 2px 12px 0;
    scroll-behavior: auto;
    scrollbar-color: color-mix(in srgb, var(--md-sys-outline) 34%, transparent) transparent;
    scrollbar-width: thin;
}
.advice-bubble[data-advice-latest="true"],
.advice-date-group:last-child {
    scroll-margin-bottom: 16px;
}
.advice-chat-list::-webkit-scrollbar { width: 4px; }
.advice-chat-list::-webkit-scrollbar-track { background: transparent; }
.advice-chat-list::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--md-sys-outline) 30%, transparent);
    border-radius: var(--md-sys-shape-full);
}
.advice-chat-list:hover::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--md-sys-outline) 48%, transparent);
}
.advice-new-message-btn {
    position: absolute;
    right: 10px;
    bottom: 96px;
    z-index: 4;
    min-height: 36px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    padding: 0 14px;
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-size: 12px;
    font-weight: 900;
    box-shadow: var(--md-sys-elevation-2);
}
.advice-date-group { display: grid; gap: 8px; }
.advice-date-head {
    border: none;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    text-align: left;
}
.advice-date-head strong { flex: 1; font-size: 13px; }
.advice-date-head small { color: var(--md-sys-on-surface-variant); font-weight: 700; }
.advice-date-head .material-symbols-rounded { font-size: 18px; color: var(--md-sys-primary); }
.advice-date-content { display: flex; flex-direction: column; gap: 8px; }
.advice-date-group.collapsed .advice-date-content { display: none; }
.advice-bubble {
    max-width: 88%;
    padding: 12px 14px;
    border-radius: 18px;
    background: var(--md-sys-surface-container-lowest);
    display: grid;
    gap: 6px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.advice-bubble.user {
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}
.advice-bubble.assistant {
    align-self: flex-start;
    max-width: 96%;
    border-bottom-left-radius: 6px;
    background: var(--md-sys-surface-container-lowest);
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 72%, transparent);
}
.advice-bubble.pending { opacity: 0.86; }
.advice-bubble.error { background: var(--md-sys-error-container); color: var(--md-sys-on-error-container); }
.advice-bubble-head { display: flex; align-items: center; gap: 8px; }
.advice-bubble b { flex: 1; font-size: 11px; color: var(--md-sys-on-surface-variant); display: flex; align-items: center; gap: 6px; }
.advice-bubble b small { font-size: 10px; font-weight: 600; color: var(--md-sys-on-surface-variant); opacity: 0.8; }
.advice-bubble.user b,
.advice-bubble.user b small,
.advice-bubble.user .advice-bubble-content,
.advice-bubble.user p { color: var(--md-sys-on-primary-container); }
.advice-bubble.error b,
.advice-bubble.error b small,
.advice-bubble.error .advice-bubble-content,
.advice-bubble.error p { color: var(--md-sys-on-error-container); }
.advice-bubble-content {
    color: var(--md-sys-on-surface);
    font-size: 14px;
    line-height: 1.68;
    min-height: 1.68em;
    overflow-wrap: anywhere;
}
.advice-bubble.assistant .advice-bubble-content,
.advice-bubble.assistant .advice-bubble-content p,
.advice-bubble.assistant .advice-bubble-content li,
.advice-bubble.assistant .advice-bubble-content h1,
.advice-bubble.assistant .advice-bubble-content h2,
.advice-bubble.assistant .advice-bubble-content h3 { color: var(--md-sys-on-surface); }
.advice-bubble.user .advice-bubble-content,
.advice-bubble.user .advice-bubble-content p { color: var(--md-sys-on-primary-container); }
.advice-bubble-content p {
    margin: 0.35em 0;
    font-size: inherit;
    line-height: inherit;
    white-space: normal;
}
.advice-bubble-content h1,
.advice-bubble-content h2,
.advice-bubble-content h3 {
    margin: 0.75em 0 0.35em;
    line-height: 1.3;
    font-weight: 800;
}
.advice-bubble-content h1:first-child,
.advice-bubble-content h2:first-child,
.advice-bubble-content h3:first-child,
.advice-bubble-content p:first-child { margin-top: 0; }
.advice-bubble-content h1 { font-size: 17px; }
.advice-bubble-content h2 { font-size: 16px; }
.advice-bubble-content h3 { font-size: 15px; }
.advice-bubble-content ul {
    margin: 0.35em 0 0.45em;
    padding-left: 1.25em;
}
.advice-bubble-content li {
    margin: 0.25em 0;
    line-height: 1.62;
}
.advice-bubble-content strong { font-weight: 800; }
.advice-bubble-content code {
    padding: 0.12em 0.35em;
    border-radius: 6px;
    background: var(--md-sys-surface-container-high);
    font-size: 0.92em;
}
.advice-bubble-content pre {
    overflow-x: auto;
    margin: 0.45em 0;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container);
}
.advice-bubble-content pre code {
    padding: 0;
    background: transparent;
    font-size: 12px;
}
.advice-bubble p { font-size: inherit; line-height: inherit; white-space: normal; }
.advice-delete-btn {
    border: none;
    width: 28px;
    height: 28px;
    border-radius: var(--md-sys-shape-full);
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.advice-delete-btn:active { background: var(--md-sys-error-container); color: var(--md-sys-on-error-container); }
.advice-delete-btn .material-symbols-rounded { font-size: 17px; }
.advice-bubble-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}
.advice-bubble-actions button {
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: color-mix(in srgb, var(--md-sys-surface-container) 78%, transparent);
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    font-weight: 800;
    min-height: 26px;
    padding: 0 10px;
    cursor: pointer;
}
.advice-bubble.user .advice-bubble-actions button {
    background: color-mix(in srgb, var(--md-sys-on-primary-container) 12%, transparent);
    color: var(--md-sys-on-primary-container);
}
.advice-routine-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.advice-routine-actions .md-btn {
    min-height: 40px;
    font-size: 12px;
}
.advice-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--md-sys-tertiary);
    animation: advicePulse 0.9s ease-in-out infinite alternate;
}
@keyframes advicePulse { from { opacity: 0.35; transform: scale(0.8); } to { opacity: 1; transform: scale(1.2); } }
.advice-composer {
    position: relative;
    width: 100%;
    max-width: 504px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 6px 6px 8px;
    border-radius: 28px;
    background: var(--md-sys-surface-container-highest);
    border: none;
    box-shadow:
        0 1px 3px 1px rgba(0,0,0,0.08),
        0 1px 2px rgba(0,0,0,0.1);
    z-index: 5;
    flex: none;
    transition:
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.advice-model-picker {
    width: 58px;
    height: 40px;
    border: none;
    border-radius: var(--md-sys-shape-full);
    background: var(--advice-model-bg, linear-gradient(135deg, var(--md-sys-secondary-container), var(--md-sys-tertiary-container)));
    color: var(--advice-model-color, var(--md-sys-on-secondary-container));
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px;
    padding: 0 6px 0 8px;
    flex: none;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    box-shadow: var(--md-sys-elevation-1);
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}
.advice-model-picker::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--md-sys-motion-duration-short);
}
.advice-model-picker:hover::after { opacity: var(--md-state-hover); }
.advice-model-picker:active { transform: scale(0.96); }
.advice-model-picker:active::after { opacity: var(--md-state-press); }
.advice-model-picker:focus-within {
    box-shadow:
        0 0 0 2px var(--md-sys-surface),
        0 0 0 4px var(--md-sys-primary),
        var(--md-sys-elevation-1);
}
.advice-model-openai { --advice-model-bg: linear-gradient(135deg, #e7faed, #c7f2d8); --advice-model-color: #064e3b; --advice-model-mark-bg: rgba(6, 78, 59, 0.12); }
.advice-model-gemini { --advice-model-bg: linear-gradient(135deg, #e3ecff, #eceaff); --advice-model-color: #2330a3; --advice-model-mark-bg: rgba(35, 48, 163, 0.12); }
.advice-model-grok { --advice-model-bg: linear-gradient(135deg, #111827, #475569); --advice-model-color: #f8fafc; --advice-model-mark-bg: rgba(255, 255, 255, 0.14); }
.advice-model-deepseek { --advice-model-bg: linear-gradient(135deg, #e2ecff, #bfd5fe); --advice-model-color: #1e3a8a; --advice-model-mark-bg: rgba(30, 58, 138, 0.12); }
.advice-model-claude { --advice-model-bg: linear-gradient(135deg, #fff5d6, #ffefb8); --advice-model-color: #7c2d12; --advice-model-mark-bg: rgba(124, 45, 18, 0.10); }
.advice-model-qwen { --advice-model-bg: linear-gradient(135deg, #dfe8ff, #d6f4fb); --advice-model-color: #25248b; --advice-model-mark-bg: rgba(37, 36, 139, 0.12); }
.advice-model-doubao { --advice-model-bg: linear-gradient(135deg, #fee5e4, #ffdcab); --advice-model-color: #7c2412; --advice-model-mark-bg: rgba(124, 36, 18, 0.10); }
.advice-model-kimi { --advice-model-bg: linear-gradient(135deg, #dbeafe, #e7eaff); --advice-model-color: #17397b; --advice-model-mark-bg: rgba(23, 57, 123, 0.10); }
.advice-model-minimax { --advice-model-bg: linear-gradient(135deg, #c9f7ef, #dcfad4); --advice-model-color: #0f5132; --advice-model-mark-bg: rgba(15, 81, 50, 0.12); }
.advice-model-mimo { --advice-model-bg: linear-gradient(135deg, #fbeefe, #eceaff); --advice-model-color: #6b1068; --advice-model-mark-bg: rgba(107, 16, 104, 0.12); }
.advice-model-glm { --advice-model-bg: linear-gradient(135deg, #e3ecff, #d6cdfb); --advice-model-color: #232882; --advice-model-mark-bg: rgba(35, 40, 130, 0.12); }
.advice-model-generic { --advice-model-bg: linear-gradient(135deg, var(--md-sys-secondary-container), var(--md-sys-tertiary-container)); --advice-model-color: var(--md-sys-on-secondary-container); --advice-model-mark-bg: var(--md-sys-surface-container-highest); }
.advice-model-mark {
    min-width: 0;
    width: 28px;
    height: 28px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 950;
    letter-spacing: -0.25px;
    justify-self: center;
    overflow: hidden;
    background: var(--advice-model-mark-bg, color-mix(in srgb, var(--md-sys-surface-container-highest) 68%, transparent));
    position: relative;
    z-index: 1;
}
.advice-model-icon {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
    border-radius: 0;
}
.advice-model-picker-arrow {
    font-size: 16px;
    color: currentColor;
    opacity: 0.76;
    position: relative;
    z-index: 1;
}
.advice-model-switch {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    border: none;
    outline: none;
    background: transparent;
    color: transparent;
    opacity: 0;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
.advice-model-switch option {
    color: var(--md-sys-on-surface);
    background: var(--md-sys-surface-container-lowest);
}
.advice-composer:focus-within {
    box-shadow:
        0 2px 6px 2px rgba(0,0,0,0.08),
        0 1px 2px rgba(0,0,0,0.1),
        0 0 0 2px color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
    background: var(--md-sys-surface-container-lowest);
}
.advice-composer-input {
    width: 100%;
    height: 44px;
    min-height: 44px;
    max-height: 160px;
    resize: none;
    overflow-y: hidden;
    border: none;
    outline: none;
    background: transparent;
    color: var(--md-sys-on-surface);
    font: inherit;
    font-size: 14px;
    line-height: 20px;
    padding: 12px 0;
    display: block;
    box-sizing: border-box;
    scrollbar-width: none;
}
.advice-composer-input::-webkit-scrollbar {
    display: none;
}
.advice-composer-input.is-scrollable {
    overflow-y: auto;
}
.advice-composer-input::placeholder {
    color: var(--md-sys-on-surface-variant);
    opacity: 0.7;
}
.advice-send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 22px;
    background: var(--md-sys-primary);
    color: var(--md-sys-on-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex: none;
    transition:
        transform var(--md-sys-motion-duration-medium) var(--md-expressive-spring),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
    box-shadow:
        0 1px 3px 1px rgba(0,0,0,0.1),
        0 1px 2px rgba(0,0,0,0.1);
}
.advice-send-btn .material-symbols-rounded {
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-variation-settings: 'FILL' 1;
}
.advice-send-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}
.advice-send-btn:hover {
    box-shadow:
        0 2px 6px 2px rgba(0,0,0,0.08),
        0 1px 2px rgba(0,0,0,0.1);
}
.advice-send-btn:hover::after { opacity: var(--md-state-hover); }
.advice-send-btn:active {
    transform: scale(0.92);
}
.advice-send-btn:active::after { opacity: var(--md-state-press); }
.advice-send-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
.advice-send-btn:disabled::after { display: none; }
.advice-status-line {
    margin: 0 auto;
    max-width: 496px;
    min-height: 18px;
    text-align: center;
    font-size: 11px;
    flex: none;
    pointer-events: none;
}
.advice-empty { align-self: stretch; }
.advice-bubble.assistant p { color: var(--md-sys-on-surface); }
.advice-bubble.assistant.error p { color: var(--md-sys-on-error-container); }

.advice-composer-tail {
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 0 calc(8px + env(safe-area-inset-bottom));
    background: var(--md-sys-surface);
    z-index: 4;
}



/* TASK-21: AI advice quick-prompts horizontal snap (M3 Expressive) */
.advice-quick-prompts {
    display: flex !important; gap: 8px;
    overflow-x: auto; scroll-snap-type: x mandatory;
    padding-bottom: 4px; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.advice-quick-prompts::-webkit-scrollbar { display: none; }
.advice-quick-prompts > button {
    flex: none; scroll-snap-align: start;
    transition: transform .25s var(--md-expressive-spring),
                background .25s ease;
}
.advice-quick-prompts > button:active { transform: scale(.92) rotate(-1deg); }
}
@layer components {
/* --- View Transitions --- */
::view-transition-old(root) {
    animation: view-fade-out 80ms var(--md-sys-motion-standard-accelerate, cubic-bezier(.3,0,1,1)) both;
}

::view-transition-new(root) {
    animation: view-fade-in 200ms var(--md-sys-motion-standard-decelerate, cubic-bezier(0,0,.2,1)) both;
}

@keyframes view-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes view-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

}
@layer components {
/* --- Advice Model Picker --- */
.advice-model-chip {
    width: 48px;
    height: 48px;
    min-height: 48px;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-full);
    background: var(--advice-model-bg, var(--md-sys-surface-container-low));
    color: var(--advice-model-color, var(--md-sys-on-surface));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0;
    font-weight: 800;
    white-space: nowrap;
}

.advice-model-chip.is-override {
    width: auto;
    padding: 0 6px 0 12px;
    border-color: color-mix(in srgb, var(--md-sys-tertiary) 34%, var(--md-sys-outline-variant));
}

.model-picker-row img {
    width: 18px;
    height: 18px;
}

.advice-model-chip small {
    display: none;
    font-size: 10px;
    color: inherit;
    opacity: .76;
}

.advice-model-chip-x {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    background: color-mix(in srgb, currentColor 12%, transparent);
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.model-picker-body {
    display: grid;
    gap: 10px;
}

.model-picker-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.model-picker-tabs::-webkit-scrollbar {
    display: none;
}

.model-picker-tab {
    min-height: 36px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    padding: 0 12px;
    font-weight: 800;
    white-space: nowrap;
}

.model-picker-tab.active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}

.model-picker-row {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-align: left;
}

.model-picker-row .advice-model-mark {
    flex: none;
}

.model-picker-row.is-selected {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}

.model-picker-row[aria-disabled="true"] {
    opacity: .48;
    pointer-events: none;
}

.model-picker-main {
    min-width: 0;
    flex: 1;
    display: grid;
    gap: 2px;
}

.model-picker-main strong,
.model-picker-main small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.advice-temp-model {
    display: inline-flex;
    align-items: center;
    border-radius: var(--md-sys-shape-full);
    padding: 1px 6px;
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-size: 10px;
    font-weight: 800;
}

}
@layer components {
/* --- Action History & Weekly Plan --- */
.action-history-controls {
    display: grid;
    gap: 8px;
}

.action-history-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.action-history-tabs::-webkit-scrollbar {
    display: none;
}

.action-history-tab {
    min-height: 36px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    padding: 0 12px;
    font-weight: 800;
    white-space: nowrap;
}

.action-history-tab.active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}

.action-history-chart {
    width: 100%;
    min-height: 180px;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-low);
}

.action-history-list {
    display: grid;
    gap: 8px;
}

.action-history-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-low);
}

.action-history-row small {
    grid-column: 1 / -1;
    color: var(--md-sys-on-surface-variant);
}

.action-history-pr {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-size: 12px;
    font-weight: 800;
}

.sl-name-row {
    display: grid;
    grid-template-columns: 1fr 40px;
    gap: 8px;
    align-items: center;
}
.sl-name-row > .md-icon-btn {
    align-self: center;
}

.weekly-plan-strip {
    display: grid;
    grid-template-columns: repeat(7, minmax(52px, 1fr));
    gap: 6px;
    overflow-x: hidden;
    padding: 0 8px 8px;
    scrollbar-width: none;
}

.weekly-plan-strip::-webkit-scrollbar {
    display: none;
}

.weekly-plan-chip {
    min-width: 0;
    min-height: 52px;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface);
    display: grid;
    align-content: center;
    gap: 2px;
    padding: 6px;
    text-align: center;
    overflow: hidden;
}

.weekly-plan-chip.is-today {
    border-color: var(--md-sys-primary);
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}

.weekly-plan-chip span {
    font-weight: 900;
    font-size: 12px;
}

.weekly-plan-chip small {
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .weekly-plan-strip {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 4px;
        padding: 0 6px 6px;
    }

    .weekly-plan-chip {
        min-height: 48px;
        padding: 5px 2px;
        border-radius: var(--md-sys-shape-md);
    }

    .weekly-plan-chip span {
        font-size: 11px;
    }

    .weekly-plan-chip small {
        font-size: 9px;
    }
}

@media (max-width: 360px) {
    .weekly-plan-strip {
        gap: 3px;
        padding-inline: 4px;
    }

    .weekly-plan-chip {
        min-height: 44px;
    }

    .weekly-plan-chip span {
        font-size: 10px;
    }
}

.weekly-plan-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 16px;
    padding: 10px 12px;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}

.weekly-plan-banner strong {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.weekly-plan-banner.is-empty {
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface-variant);
}

.weekly-plan-picker {
    display: grid;
    gap: 8px;
}


/* TASK-24: Weekly summary card rise (M3 Expressive) */
.weekly-summary-card { animation: m3e-card-rise .42s var(--md-expressive-spring) both; }
}
@layer components {
/* --- Plan Daily Plan / M3E --- */
:root {
    --plan-type-rehab: var(--md-sys-tertiary);
    --plan-type-cut: var(--md-sys-error);
    --plan-type-bulk: var(--md-sys-primary);
    --plan-type-maintenance: var(--md-sys-secondary);
    --plan-type-custom: var(--md-sys-outline);
}

.plan-hero-card {
    border-radius: 28px;
    animation: m3e-card-rise .3s var(--md-expressive-spring) both;
    background:
        linear-gradient(0deg, color-mix(in srgb, var(--md-sys-surface-tint, var(--md-sys-primary)) 8%, transparent), transparent),
        var(--md-sys-surface-container-low);
}

.plan-today-metrics {
    display: block;
    font-weight: 800;
}

.plan-ring-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    justify-items: center;
    gap: 10px;
}

.plan-intake-ring,
.plan-progress-ring {
    width: 88px;
    height: 88px;
}

.plan-progress-ring {
    --plan-ring-color: var(--plan-type-rehab);
    border: 0;
    padding: 0;
    background:
        conic-gradient(
            from -90deg,
            var(--plan-ring-color) 0deg var(--plan-progress, 0deg),
            color-mix(in srgb, var(--plan-ring-color) 18%, var(--md-sys-surface-container-highest)) var(--plan-progress, 0deg) 360deg
        );
    color: var(--md-sys-on-surface);
    text-align: center;
    cursor: pointer;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short4, 200ms) var(--md-sys-motion-emphasized);
}

.plan-progress-ring::after {
    background: var(--md-sys-surface-container-low);
}

.plan-progress-ring:active {
    transform: scale(.96);
}

.plan-progress-ring b {
    color: var(--plan-ring-color);
}

.plan-progress-ring em {
    max-width: 58px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.is-rehab { --plan-ring-color: var(--plan-type-rehab); }
.is-cut { --plan-ring-color: var(--plan-type-cut); }
.is-bulk { --plan-ring-color: var(--plan-type-bulk); }
.is-maintenance { --plan-ring-color: var(--plan-type-maintenance); }
.is-custom { --plan-ring-color: var(--plan-type-custom); }

.plan-type-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.plan-type-tabs::-webkit-scrollbar {
    display: none;
}

.plan-type-tab {
    min-height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--md-sys-shape-lg);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    scroll-snap-align: start;
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface-variant);
    font-weight: 800;
}

.plan-type-tab.active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}

.plan-type-tab .material-symbols-rounded {
    font-size: 18px;
}

.plan-current-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 6px;
    flex: none;
    align-self: center;
}

.plan-current-actions .md-btn {
    min-width: 0;
    width: 100%;
    height: 40px;
    min-height: 40px;
    max-height: 40px;
    margin: 0;
    padding: 0 10px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    line-height: 1;
    font-size: 13px;
}

.today-action-dock {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    box-sizing: border-box;
    width: calc(100% - 32px);
    margin: 0 16px 4px;
}

.today-action-dock .record-quick-btn {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.today-action-dock .record-quick-btn span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-create-sheet {
    display: grid;
    gap: 8px;
}

.plan-create-row.active {
    border-color: color-mix(in srgb, var(--plan-ring-color, var(--md-sys-primary)) 36%, var(--md-sys-outline-variant));
    background: color-mix(in srgb, var(--plan-ring-color, var(--md-sys-primary)) 14%, var(--md-sys-surface-container-lowest));
}

.plan-create-row .material-symbols-rounded {
    color: var(--plan-ring-color, var(--md-sys-primary));
}

.plan-ai-preview-type {
    width: max-content;
    max-width: 100%;
    padding: 3px 8px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-tertiary-container);
    color: var(--md-sys-on-tertiary-container);
    font-size: 11px;
    font-weight: 900;
}
.plan-today-card,
.plan-pref-card {
    display: grid;
    gap: 12px;
    overflow: hidden;
    width: auto;
    border-color: color-mix(in srgb, var(--md-sys-primary) 22%, var(--md-sys-outline-variant));
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--md-sys-primary-container) 34%, transparent), transparent 42%),
        var(--md-sys-surface-container-low);
}

.plan-today-head,
.plan-pref-head,
.plan-feedback-head,
.plan-sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

#planFeedbackSheet {
    z-index: 240;
}

.plan-sheet-head {
    justify-content: flex-start;
}

.plan-today-head > div,
.plan-pref-head > div,
.plan-sheet-head > div {
    min-width: 0;
}

.plan-pref-head {
    align-items: center;
}

.plan-today-head h3,
.plan-pref-head h3,
.plan-feedback-head h3,
.plan-sheet-head h3 {
    margin: 4px 0;
    color: var(--md-sys-on-surface);
    font-size: var(--md-sys-typescale-title-large-size);
    line-height: var(--md-sys-typescale-title-large-line-height);
}

.plan-today-head small,
.plan-pref-head small,
.plan-feedback-head small,
.plan-sheet-head small {
    color: var(--md-sys-on-surface-variant);
    line-height: 1.45;
}

.plan-card-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    flex: none;
}

.plan-card-actions .md-icon-btn,
.plan-current-list-btn {
    position: relative;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    overflow: hidden;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    -webkit-tap-highlight-color: transparent;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-current-list-btn {
    color: var(--md-sys-on-primary-container);
}

.plan-card-actions .md-icon-btn::after,
.plan-current-list-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-card-actions .md-icon-btn:hover::after,
.plan-current-list-btn:hover::after {
    opacity: var(--md-state-hover);
}

.plan-card-actions .md-icon-btn:active,
.plan-current-list-btn:active {
    transform: scale(.92);
}

.plan-card-actions .md-icon-btn:active::after,
.plan-current-list-btn:active::after {
    opacity: var(--md-state-press);
}

.plan-card-actions .material-symbols-rounded,
.plan-current-list-btn .material-symbols-rounded {
    position: relative;
    z-index: 1;
    font-size: 22px;
}

.plan-current-list-btn b {
    position: absolute;
    top: 2px;
    right: 1px;
    z-index: 2;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-tertiary);
    color: var(--md-sys-on-tertiary);
    font-size: 10px;
    line-height: 1;
    font-weight: 900;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--md-sys-primary-container) 88%, var(--md-sys-surface-container-lowest));
}

.plan-head-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--md-sys-shape-lg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    font-size: 24px;
    font-variation-settings: 'FILL' 1;
}

.plan-equipment-open-btn {
    flex: none;
    width: auto;
    min-width: 0;
    max-width: 148px;
    height: 40px;
    padding: 0 10px;
    gap: 6px;
    white-space: nowrap;
}

.plan-equipment-open-btn .material-symbols-rounded {
    font-size: 18px;
}

.plan-equipment-open-btn small {
    min-width: 18px;
    height: 18px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--md-sys-on-secondary-container) 12%, transparent);
    color: inherit;
    font-size: 11px;
    line-height: 1;
}

.plan-stat-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.plan-stat-row span {
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 72%, transparent);
    border-radius: var(--md-sys-shape-md);
    background: color-mix(in srgb, var(--md-sys-surface-container-lowest) 78%, transparent);
}

.plan-stat-row b,
.plan-stat-row small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-stat-row b {
    color: var(--md-sys-on-surface);
    font-size: 16px;
    line-height: 20px;
}

.plan-stat-row small {
    margin-top: 2px;
    color: var(--md-sys-on-surface-variant);
    font-size: var(--md-sys-typescale-label-small-size);
    font-weight: 700;
}

.plan-progress,
.plan-cooldown-progress {
    height: 8px;
    border-radius: var(--md-sys-shape-full);
    overflow: hidden;
    background: color-mix(in srgb, var(--md-sys-surface-container-highest) 82%, transparent);
}

.plan-progress i,
.plan-cooldown-progress i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--md-sys-primary), color-mix(in srgb, var(--md-sys-primary) 64%, var(--md-sys-secondary)));
    transition: width var(--md-sys-motion-duration-medium) var(--md-expressive-spring);
}

.plan-current-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--md-sys-primary) 20%, transparent);
    border-radius: var(--md-sys-shape-lg);
    background: color-mix(in srgb, var(--md-sys-primary-container) 66%, var(--md-sys-surface-container-lowest));
    color: var(--md-sys-on-primary-container);
}

.plan-current-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    background: color-mix(in srgb, var(--md-sys-primary) 16%, transparent);
    font-variation-settings: 'FILL' 1;
}

.plan-current-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
    flex: 1 1 auto;
}

.plan-compact-list,
.plan-pref-grid,
.plan-pref-switches,
.plan-equipment-chips,
.plan-feedback-grid,
.plan-weekly-list,
.plan-weekly-detail,
.plan-queue-list,
.plan-ai-preview-items,
.plan-ai-chip-row {
    display: grid;
    gap: 8px;
}

.plan-section {
    display: grid;
    gap: 8px;
    margin-top: 4px;
}

.plan-task-drawer {
    display: grid;
    gap: 12px;
}

.plan-drawer-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container);
}

.plan-drawer-summary-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-full);
    display: inline-grid;
    place-items: center;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    font-size: 21px;
}

.plan-drawer-summary-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.plan-drawer-summary-copy strong,
.plan-drawer-summary-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-drawer-summary-copy small {
    color: var(--md-sys-on-surface-variant);
}

.plan-cancel-day-btn {
    flex: none;
    min-width: 0;
    margin: 0;
    padding: 0 12px;
    white-space: nowrap;
}

.plan-section-head,
.plan-task-row,
.plan-weekly-task,
.plan-cooldown-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.plan-section-head {
    justify-content: space-between;
    padding: 2px 2px 0;
    color: var(--md-sys-on-surface-variant);
}

.plan-section-head strong {
    color: var(--md-sys-on-surface);
}

.plan-section-head small {
    min-width: 26px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-surface-container);
    font-weight: 800;
}

.plan-task-row,
.plan-weekly-task {
    position: relative;
    min-height: 56px;
    border: 1px solid transparent;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-lowest);
    padding: 6px;
    box-shadow: 0 1px 0 color-mix(in srgb, var(--md-sys-outline-variant) 38%, transparent);
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-task-row:active,
.plan-weekly-task:active {
    transform: scale(.985);
}

.plan-task-row.is-current,
.plan-weekly-task.is-current {
    border-color: color-mix(in srgb, var(--md-sys-primary) 30%, var(--md-sys-outline-variant));
    background: color-mix(in srgb, var(--md-sys-primary-container) 62%, var(--md-sys-surface-container-lowest));
}

.plan-task-row.is-done,
.plan-weekly-task.is-done {
    background: color-mix(in srgb, var(--md-sys-secondary-container) 42%, var(--md-sys-surface-container-lowest));
}

.plan-task-row.is-skipped,
.plan-weekly-task.is-skipped {
    opacity: .72;
}

.plan-task-main,
.plan-weekly-task-main {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: var(--md-sys-shape-md);
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 2px 4px;
    -webkit-tap-highlight-color: transparent;
}

.plan-task-order {
    width: 32px;
    height: 32px;
    border-radius: var(--md-sys-shape-full);
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    font-weight: 900;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    flex: 0 0 auto;
}

.plan-task-body {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.plan-task-title {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px 8px;
}

.plan-task-title strong {
    min-width: 0;
    flex: 1 1 100%;
}

.plan-task-title em {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 22px;
    padding: 0 7px;
    border-radius: var(--md-sys-shape-full);
    background: color-mix(in srgb, var(--md-sys-surface-container-highest) 74%, transparent);
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.plan-task-title em .material-symbols-rounded {
    font-size: 15px;
}

.plan-task-row.is-current .plan-task-title em,
.plan-weekly-task.is-current .plan-weekly-task-main small {
    background: var(--md-sys-primary);
    color: var(--md-sys-on-primary);
}

.plan-task-row.is-done .plan-task-title em,
.plan-weekly-task.is-done .plan-weekly-task-main small {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}

.plan-task-body strong,
.plan-task-body small,
.plan-weekly-task-main strong,
.plan-weekly-task-main small,
.plan-current-block strong,
.plan-current-block small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-task-body small,
.plan-weekly-task-main small,
.plan-current-block small {
    color: var(--md-sys-on-surface-variant);
}

.plan-current-block small {
    color: color-mix(in srgb, var(--md-sys-on-primary-container) 78%, transparent);
}

.plan-task-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.plan-task-actions .md-icon-btn,
.plan-weekly-task > .md-icon-btn,
.plan-ai-preview-item > .md-icon-btn,
.plan-ai-preview-plan-head > .md-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    overflow: hidden;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-task-actions .md-icon-btn::after,
.plan-weekly-task > .md-icon-btn::after,
.plan-ai-preview-item > .md-icon-btn::after,
.plan-ai-preview-plan-head > .md-icon-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-task-actions .md-icon-btn:hover::after,
.plan-weekly-task > .md-icon-btn:hover::after,
.plan-ai-preview-item > .md-icon-btn:hover::after,
.plan-ai-preview-plan-head > .md-icon-btn:hover::after {
    opacity: var(--md-state-hover);
}

.plan-task-actions .md-icon-btn:active,
.plan-weekly-task > .md-icon-btn:active,
.plan-ai-preview-item > .md-icon-btn:active,
.plan-ai-preview-plan-head > .md-icon-btn:active {
    transform: scale(.92);
}

.plan-task-actions .md-icon-btn:active::after,
.plan-weekly-task > .md-icon-btn:active::after,
.plan-ai-preview-item > .md-icon-btn:active::after,
.plan-ai-preview-plan-head > .md-icon-btn:active::after {
    opacity: var(--md-state-press);
}

.plan-task-actions .material-symbols-rounded,
.plan-weekly-task > .md-icon-btn .material-symbols-rounded,
.plan-ai-preview-item > .md-icon-btn .material-symbols-rounded,
.plan-ai-preview-plan-head > .md-icon-btn .material-symbols-rounded {
    position: relative;
    z-index: 1;
    font-size: 21px;
}

.plan-empty {
    padding: 14px;
    border: 1px dashed var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    color: var(--md-sys-on-surface-variant);
    text-align: center;
    background: color-mix(in srgb, var(--md-sys-surface-container-lowest) 62%, transparent);
}

.plan-expand-btn {
    width: 100%;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 0;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
    font-weight: 800;
    -webkit-tap-highlight-color: transparent;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-expand-btn:active {
    transform: scale(.97);
}

.plan-manual-strip {
    display: block;
}

.plan-equipment-chip {
    gap: 6px;
    min-height: 40px;
}

.plan-equipment-chip .material-symbols-rounded {
    font-size: 18px;
}

.plan-pref-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.plan-pref-grid .md-field {
    min-width: 0;
    margin-bottom: 0;
}

.plan-pref-grid .md-field select {
    min-width: 0;
    font-size: 13px;
    padding-left: 8px;
    padding-right: 22px;
}

.plan-pref-grid .md-field label {
    left: 8px;
    max-width: calc(100% - 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-equipment-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.plan-equipment-chip {
    position: relative;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface);
    justify-content: flex-start;
    min-width: 0;
    min-height: 52px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.plan-equipment-chip strong {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.plan-equipment-chip.active {
    border-color: color-mix(in srgb, var(--md-sys-primary) 42%, var(--md-sys-outline-variant));
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}

.plan-equipment-chip i.material-symbols-rounded {
    margin-left: auto;
    font-style: normal;
    color: var(--md-sys-primary);
    font-size: 18px;
}

.plan-equipment-chip.active i.material-symbols-rounded {
    color: var(--md-sys-on-primary-container);
}

.plan-equipment-chip em.material-symbols-rounded {
    width: 30px;
    height: 30px;
    margin-right: -6px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-style: normal;
    color: var(--md-sys-on-surface-variant);
    font-size: 18px;
}

.plan-equipment-chip em.material-symbols-rounded:active {
    background: color-mix(in srgb, var(--md-sys-error) 14%, transparent);
    color: var(--md-sys-error);
}

.plan-equipment-add-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.plan-equipment-add-row .md-field {
    min-width: 0;
    margin: 0;
}

.plan-equipment-add-row .md-btn {
    width: auto;
    min-width: 88px;
    padding: 0 14px;
    margin: 0;
}

.plan-pref-switches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 2px 0;
}

.plan-pref-switch {
    min-width: 0;
    min-height: 74px;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 8px 6px;
    border-radius: var(--md-sys-shape-lg);
    background: color-mix(in srgb, var(--md-sys-surface-container-lowest) 72%, transparent);
    text-align: center;
    font-size: 12px;
    line-height: 1.25;
}

.plan-pref-switch > span:first-child {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.plan-pref-switch .switch-track {
    flex: none;
    transform: scale(.86);
    transform-origin: center;
}

.plan-equipment-sheet {
    display: grid;
    gap: 12px;
}

.plan-equipment-sheet-copy {
    display: grid;
    gap: 4px;
}

.plan-equipment-sheet-copy strong {
    color: var(--md-sys-on-surface);
}

.plan-equipment-sheet-copy small {
    color: var(--md-sys-on-surface-variant);
    line-height: 1.45;
}


@media (max-width: 640px) {
    .plan-pref-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .plan-pref-grid .md-field select {
        font-size: 12px;
        padding: 16px 18px 4px 7px;
    }

    .plan-pref-grid .md-field label {
        font-size: 10px;
        left: 7px;
    }

    .plan-pref-grid .md-field select:focus {
        padding: 15px 17px 3px 6px;
    }
}

@media (max-width: 480px) {
    .plan-pref-card {
        gap: 10px;
    }

    .plan-pref-head {
        gap: 8px;
    }

    .plan-pref-head h3 {
        font-size: 16px;
    }

    .plan-pref-head small {
        font-size: 11px;
    }

    .plan-today-head {
        gap: 8px;
    }

    .plan-card-actions {
        gap: 0;
    }

    .plan-card-actions .md-icon-btn,
    .plan-current-list-btn {
        width: 38px;
        min-width: 38px;
        height: 38px;
    }

    .plan-current-block {
        gap: 8px;
        padding: 10px;
        flex-wrap: wrap;
    }

    .plan-current-icon {
        width: 36px;
        height: 36px;
    }

    .plan-current-copy {
        flex-basis: calc(100% - 88px);
    }

    .plan-current-actions {
        order: 4;
        width: 100%;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .plan-current-actions .md-btn {
        height: 40px;
        min-height: 40px;
        max-height: 40px;
        margin: 0;
        padding: 0 6px;
        font-size: 12px;
    }

    .today-action-dock {
        gap: 6px;
        width: calc(100% - 16px);
        margin: 0 8px 2px;
    }

    .today-action-dock .record-quick-btn {
        padding: 8px 1px;
        font-size: 10px;
    }

    .plan-equipment-open-btn {
        max-width: 118px;
        height: 38px;
        padding: 0 8px;
        font-size: 12px;
    }

    .plan-stat-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .plan-feedback-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .plan-equipment-chips {
        grid-template-columns: 1fr 1fr;
    }

    .plan-equipment-add-row {
        grid-template-columns: minmax(0, 1fr) 80px;
    }

    .plan-equipment-add-row .md-btn {
        min-width: 0;
        padding: 0 8px;
        gap: 4px;
    }

    .plan-pref-switches {
        gap: 6px;
    }

    .plan-pref-switch {
        min-height: 70px;
        padding: 7px 4px;
        font-size: 11px;
    }

    .plan-ai-preview-spec {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .plan-task-actions {
        gap: 0;
    }

    .plan-task-actions .md-icon-btn {
        width: 36px;
    }

    .plan-task-drawer .plan-task-row {
        align-items: flex-start;
    }

    .plan-drawer-summary {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 8px;
        padding: 8px;
    }

    .plan-cancel-day-btn {
        height: 38px;
        min-height: 38px;
        padding: 0 8px;
        font-size: 12px;
        gap: 4px;
    }

}

@media (max-width: 360px) {
    .plan-equipment-open-btn span:not(.material-symbols-rounded) {
        display: none;
    }

    .plan-equipment-open-btn {
        width: 64px;
        justify-content: center;
    }

    .plan-pref-grid {
        gap: 4px;
    }

    .plan-pref-grid .md-field select {
        font-size: 11px;
        padding-left: 6px;
        padding-right: 16px;
    }

    .plan-pref-switch {
        font-size: 10.5px;
    }

    .plan-pref-switch .switch-track {
        transform: scale(.78);
    }

    .plan-card-actions .md-icon-btn,
    .plan-current-list-btn {
        width: 36px;
        min-width: 36px;
        height: 36px;
    }

    .plan-current-list-btn b {
        right: -1px;
    }

    .today-action-dock {
        width: calc(100% - 12px);
        margin: 0 6px 2px;
        gap: 4px;
    }

    .today-action-dock .record-quick-btn {
        min-height: 56px;
        padding: 6px 0;
        font-size: 9px;
    }
}

}
@layer components {
/* --- Plan AI / Weekly / Feedback / Cooldown --- */
.plan-feedback-sheet,
.plan-ai-sheet,
.plan-weekly-sheet,
.plan-ai-preview {
    display: grid;
    gap: 12px;
}

.plan-ai-status {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 72%, transparent);
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    line-height: 1.35;
}

.plan-ai-status.is-busy {
    border-color: color-mix(in srgb, var(--md-sys-primary) 36%, transparent);
    background: color-mix(in srgb, var(--md-sys-primary-container) 52%, var(--md-sys-surface-container-low));
    color: var(--md-sys-on-primary-container);
}

.plan-ai-status.is-error {
    border-color: color-mix(in srgb, var(--md-sys-error) 48%, transparent);
    background: color-mix(in srgb, var(--md-sys-error-container) 54%, var(--md-sys-surface-container-low));
    color: var(--md-sys-on-error-container);
}

.plan-feedback-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.plan-feedback-btn {
    position: relative;
    min-height: 88px;
    border: 1px solid transparent;
    border-radius: var(--md-sys-shape-xl);
    display: grid;
    gap: 6px;
    place-items: center;
    overflow: hidden;
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface);
    font-weight: 800;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-feedback-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity var(--md-sys-motion-duration-short);
}

.plan-feedback-btn:active {
    transform: scale(.94);
}

.plan-feedback-btn:active::after {
    opacity: var(--md-state-press);
}

.plan-feedback-btn.active {
    border-color: color-mix(in srgb, var(--md-sys-primary) 36%, transparent);
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}

.plan-feedback-emoji {
    position: relative;
    z-index: 1;
    font-size: 28px;
    line-height: 1;
}

.plan-feedback-btn strong {
    position: relative;
    z-index: 1;
}

.plan-feedback-sheet .md-field textarea,
.plan-ai-sheet .md-field textarea {
    width: 100%;
    min-height: 108px;
    padding: 18px 12px 8px;
    border: 1.5px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-sm);
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface);
    font: inherit;
    font-size: 16px;
    line-height: 1.45;
    resize: vertical;
    outline: none;
    transition:
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-feedback-sheet .md-field textarea:focus,
.plan-ai-sheet .md-field textarea:focus {
    border-color: var(--md-sys-primary);
    border-width: 2px;
    padding: 17px 11px 7px;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-primary) 14%, transparent);
}

.plan-feedback-sheet .md-field textarea::placeholder,
.plan-ai-sheet .md-field textarea::placeholder {
    color: transparent;
}

.plan-feedback-sheet .md-field textarea:focus + label,
.plan-feedback-sheet .md-field textarea:not(:placeholder-shown) + label,
.plan-ai-sheet .md-field textarea:focus + label,
.plan-ai-sheet .md-field textarea:not(:placeholder-shown) + label {
    top: 5px;
    transform: translateY(0);
    color: var(--md-sys-primary);
    font-size: 10px;
    font-weight: 600;
}

.plan-cooldown-toast {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    z-index: 36;
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 62%, transparent);
    border-radius: var(--md-sys-shape-xl);
    background: color-mix(in srgb, var(--md-sys-surface-container-low) 88%, transparent);
    backdrop-filter: blur(20px);
    box-shadow: var(--md-sys-elevation-3);
    animation: m3e-card-rise .32s var(--md-expressive-spring) both;
}

.plan-cooldown-toast-head {
    display: grid;
    gap: 4px;
}

.plan-cooldown-toast-head small {
    color: var(--md-sys-on-surface-variant);
}

.plan-cooldown-actions {
    flex-wrap: wrap;
}

.plan-cooldown-progress {
    height: 5px;
}

.plan-workout-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px auto 0;
    padding: 8px 12px;
    width: fit-content;
    max-width: 100%;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    box-shadow: var(--md-sys-elevation-1);
}

.plan-workout-banner .material-symbols-rounded {
    font-size: 20px;
    font-variation-settings: 'FILL' 1;
}

.plan-workout-banner small {
    color: inherit;
    opacity: .76;
}

.plan-weekly-list {
    grid-template-columns: repeat(7, minmax(112px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.plan-weekly-list::-webkit-scrollbar {
    display: none;
}

.plan-weekly-day {
    position: relative;
    width: 100%;
    min-height: 82px;
    border: 1px solid transparent;
    border-radius: var(--md-sys-shape-lg);
    padding: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24px;
    gap: 8px;
    align-items: start;
    overflow: hidden;
    background: var(--md-sys-surface-container-low);
    color: var(--md-sys-on-surface);
    text-align: left;
    scroll-snap-align: start;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-expressive-spring),
        background var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized);
}

.plan-weekly-day:active {
    transform: scale(.96);
}

.plan-weekly-day.active {
    border-color: color-mix(in srgb, var(--md-sys-primary) 36%, transparent);
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}

.plan-weekly-day.is-drop-target {
    outline: 3px solid color-mix(in srgb, var(--md-sys-primary) 42%, transparent);
    outline-offset: 2px;
}

.plan-weekly-day strong,
.plan-weekly-day small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-weekly-day small {
    margin-top: 2px;
    color: inherit;
    opacity: .74;
}

.plan-weekly-day > .material-symbols-rounded {
    justify-self: end;
    font-size: 20px;
    color: inherit;
    opacity: .82;
}

.plan-weekly-day-progress {
    grid-column: 1 / -1;
    align-self: end;
    height: 5px;
    border-radius: var(--md-sys-shape-full);
    overflow: hidden;
    background: color-mix(in srgb, currentColor 13%, transparent);
}

.plan-weekly-day-progress i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: currentColor;
    opacity: .82;
}

.plan-weekly-detail {
    min-height: 72px;
}

.plan-weekly-task-main {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 8px;
}

.plan-weekly-task-main > .material-symbols-rounded {
    color: var(--md-sys-primary);
    font-size: 21px;
}

.plan-weekly-task-main small {
    height: 22px;
    padding: 0 8px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    background: color-mix(in srgb, var(--md-sys-surface-container-highest) 76%, transparent);
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
    font-weight: 800;
}

.plan-weekly-drag-ghost {
    position: fixed;
    z-index: 80;
    pointer-events: none;
    width: min(280px, calc(100vw - 32px));
    transform: translate(-50%, -50%) scale(.98);
    opacity: .94;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    box-shadow: var(--md-sys-elevation-3);
    padding: 6px;
}

.plan-ai-chip-row {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.plan-ai-chip-row::-webkit-scrollbar {
    display: none;
}

.plan-ai-chip-row .md-chip {
    flex: none;
}

.plan-ai-type-chip {
    border: 1px solid transparent;
}

.plan-ai-type-chip.active {
    border-color: color-mix(in srgb, var(--md-sys-primary) 44%, transparent);
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
}

.plan-ai-type-chip .material-symbols-rounded {
    font-size: 16px;
}

.plan-ai-preview-plan {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-xl);
    background: var(--md-sys-surface-container-low);
}

.plan-ai-preview-plan-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    align-items: center;
}

.plan-ai-preview-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 10px;
    align-items: start;
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--md-sys-outline-variant) 72%, transparent);
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-lowest);
}

.plan-ai-preview-name,
.plan-ai-preview-category,
.plan-ai-preview-reason,
.plan-ai-preview-spec {
    grid-column: 1 / 2;
}

.plan-ai-preview-spec {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
}

.plan-ai-preview-alt {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1.5px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-sm);
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
    font-weight: 700;
}

.plan-ai-preview-alt input {
    width: 18px;
    height: 18px;
    accent-color: var(--md-sys-primary);
}

.plan-ai-preview-item > .md-icon-btn {
    grid-column: 2 / 3;
    grid-row: 1 / span 3;
}

.plan-save-routine-sheet {
    display: grid;
    gap: 6px;
    color: var(--md-sys-on-surface-variant);
    font-size: 14px;
}

.plan-ai-raw pre {
    max-height: 240px;
    overflow: auto;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-low);
    padding: 10px;
    white-space: pre-wrap;
}
}
@layer components {
/* ============================================
   V6 UI — Glass language + Global safety nets + Animations
   Page-level styles moved to 51..56 v6 partials.
   Dark glass tokens live in 37-dark-mode.css.
   ============================================ */

/* ======================
   GLOBAL — glass safety nets
   ====================== */

.md-card { transition: background 0.6s var(--md-sys-motion-emphasized), box-shadow 0.6s var(--md-sys-motion-emphasized); }

.page > .md-card,
.page > .glass-card,
.page > .timer-panel,
.page > .input-card {
    margin-left: 0;
    margin-right: 0;
}

.md-card,
.glass-card,
.hero,
.timer-panel,
.ai-hero,
.profile-hero,
.stat-tile,
.md-field,
.md-btn,
.md-chip,
.setting-row,
.nav-item,
.nav-content {
    min-width: 0;
}

.md-btn,
.md-chip,
.plan-chip,
.streak-chip,
.mode-tab,
.record-tab,
.setting-row .copy,
.profile-info,
.sect-head,
.plan-card .plan-head,
.calorie-head,
.ai-input,
.ai-msg,
.ai-hero p,
.profile-info h2,
.profile-info small,
.setting-row .copy strong,
.setting-row .copy small,
.stat-tile .val,
.stat-tile .delta {
    overflow-wrap: anywhere;
}

.app-title,
.today-v6-greet-line,
.today-v6-greet-sub,
.plan-card .pn,
.plan-chip,
.mode-tab,
.record-tab,
.setting-row .copy strong,
.setting-row .copy small,
.stat-tile .val,
.stat-tile .delta,
.nav-item small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-leading,
.bar-trailing,
.today-v6-greet {
    min-width: 0;
}

.bar-leading { flex: 1 1 auto; }
.bar-trailing { flex: 0 1 auto; }

.md-icon-btn-bar {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    transition: background 0.15s;
}
.md-icon-btn-bar::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 50%;
    background: var(--md-sys-on-surface);
    opacity: 0;
    transition: opacity 0.15s;
}
.md-icon-btn-bar:hover::after { opacity: 0.08; }
.md-icon-btn-bar:active::after { opacity: 0.12; }
.md-icon-btn-bar .material-symbols-rounded { font-size: 22px; position: relative; z-index: 1; }

.glass-card {
    background: var(--glass-bg-strong);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 16px;
    box-shadow: var(--glass-shadow-inset), var(--glass-shadow-out);
    margin-bottom: 12px;
}

.sect-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px;
    margin-bottom: 8px;
}
.sect-head .t { font-size: 13px; font-weight: 600; color: var(--md-sys-on-surface); }
.sect-head .a { font-size: 12px; color: var(--md-sys-primary); cursor: pointer; background: none; border: none; font-weight: 600; }

/* ======================
   ANIMATIONS — V6 keyframes
   ====================== */

@keyframes orb { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(8px, -12px) scale(1.08); } }
@keyframes glass-breathe { 0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.72), inset 0 -1px 2px rgba(0,29,54,0.06), 0 10px 28px color-mix(in srgb, var(--md-sys-primary) 16%, transparent); } 50% { box-shadow: inset 0 1px 0 rgba(255,255,255,0.86), inset 0 -1px 2px rgba(0,29,54,0.05), 0 14px 34px color-mix(in srgb, var(--md-sys-primary) 24%, transparent); } }
@keyframes ring-breathe { 0%, 100% { filter: saturate(1) drop-shadow(0 0 0 transparent); } 50% { filter: saturate(1.12) drop-shadow(0 6px 16px color-mix(in srgb, var(--md-sys-primary) 18%, transparent)); } }
@keyframes fab-glow { 0%, 100% { box-shadow: 0 6px 18px color-mix(in srgb, var(--md-sys-primary) 35%, transparent); } 50% { box-shadow: 0 8px 28px color-mix(in srgb, var(--md-sys-primary) 55%, transparent); } }
@keyframes flame { 0%, 100% { transform: scale(1) rotate(-3deg); } 50% { transform: scale(1.15) rotate(3deg); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--md-sys-primary) 18%, transparent); } 50% { box-shadow: 0 0 0 9px color-mix(in srgb, var(--md-sys-primary) 6%, transparent); } }
@keyframes seg-pulse { 0%, 100% { transform: scaleX(0.35); opacity: 0.55; } 50% { transform: scaleX(0.85); opacity: 0.95; } }
@keyframes bar-grow { from { width: 0 !important; opacity: 0; } to { opacity: 1; } }
@keyframes ai-breath { 0%, 100% { transform: scale(1); box-shadow: 0 6px 18px color-mix(in srgb, var(--md-sys-primary) 35%, transparent); } 50% { transform: scale(1.05); box-shadow: 0 8px 24px color-mix(in srgb, var(--md-sys-primary) 55%, transparent); } }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; } }

}
@layer components {
/* --- V6 Today (hero / rings / quick-dock / plan-card / calorie / macros / timeline) --- */

.hero {
    background:
        linear-gradient(145deg, rgba(255,255,255,0.44), rgba(255,255,255,0.13) 46%, rgba(255,255,255,0.28)),
        linear-gradient(135deg, color-mix(in srgb, var(--md-sys-primary-container) 95%, white) 0%, color-mix(in srgb, var(--md-sys-tertiary-container) 62%, var(--md-sys-primary-container)) 100%);
    backdrop-filter: blur(24px) saturate(170%);
    -webkit-backdrop-filter: blur(24px) saturate(170%);
    border: 1px solid rgba(255,255,255,0.58);
    border-radius: 28px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.72),
        inset 0 -1px 2px rgba(0,29,54,0.06),
        0 10px 28px color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
    animation: glass-breathe 6s var(--md-sys-motion-emphasized) infinite;
    transition: background 0.6s var(--md-sys-motion-emphasized), box-shadow 0.6s var(--md-sys-motion-emphasized);
}
.hero::before {
    content: '';
    position: absolute;
    inset: 1px 10px auto;
    height: 42%;
    border-radius: 26px 26px 50% 50% / 100% 100% 30% 30%;
    background: linear-gradient(180deg, rgba(255,255,255,0.55), transparent);
    pointer-events: none;
}
.hero::after {
    content: '';
    position: absolute;
    right: -52px;
    bottom: -64px;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(255,255,255,0.52), transparent 66%);
    pointer-events: none;
}
[data-theme-mode="dark"] .hero {
    background:
        linear-gradient(145deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03) 52%, rgba(255,255,255,0.07)),
        linear-gradient(135deg, color-mix(in srgb, var(--md-sys-primary-container) 36%, var(--md-sys-surface-container)), color-mix(in srgb, var(--md-sys-tertiary-container) 22%, var(--md-sys-surface-container-low)));
    border-color: color-mix(in srgb, var(--md-sys-on-surface) 16%, transparent);
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, var(--md-sys-on-surface) 10%, transparent),
        0 12px 30px rgba(0,0,0,0.35);
}
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; position: relative; z-index: 2; gap: 8px; }
.hero-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--md-sys-on-primary-container); opacity: 0.72; }
.hero-title { font-size: 18px; font-weight: 600; color: var(--md-sys-on-primary-container); margin-top: 4px; letter-spacing: -0.2px; }
.streak-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,0.55); backdrop-filter: blur(14px) saturate(160%); -webkit-backdrop-filter: blur(14px) saturate(160%); border: 1px solid rgba(255,255,255,0.58); font-size: 11px; font-weight: 700; color: var(--md-sys-on-primary-container); box-shadow: inset 0 1px 0 rgba(255,255,255,0.65); }
.streak-chip .material-symbols-rounded { font-size: 14px; color: #f59e0b; animation: flame 1.5s ease-in-out infinite; display: inline-block; }

.rings { display: flex; justify-content: space-around; align-items: center; background: rgba(255,255,255,0.32); backdrop-filter: blur(22px) saturate(170%); -webkit-backdrop-filter: blur(22px) saturate(170%); border: 1px solid rgba(255,255,255,0.58); border-radius: 28px; padding: 14px 10px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.68), 0 4px 16px rgba(0,29,54,0.06); position: relative; z-index: 2; }
.rings::before { content: ''; position: absolute; top: 1px; left: 8%; right: 8%; height: 38%; border-radius: 28px 28px 50% 50% / 100% 100% 30% 30%; background: linear-gradient(180deg, rgba(255,255,255,0.5), transparent); pointer-events: none; }
[data-theme-mode="dark"] .rings { background: color-mix(in srgb, var(--md-sys-surface-container-high) 56%, transparent); border-color: color-mix(in srgb, var(--md-sys-on-surface) 14%, transparent); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--md-sys-on-surface) 8%, transparent), 0 6px 18px rgba(0,0,0,0.24); }
.ring-divider { width: 1px; height: 60px; background: linear-gradient(180deg, transparent, rgba(0,29,54,0.18), transparent); border-radius: 1px; }

.hero .plan-type-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.3); position: relative; z-index: 2; }
.hero .plan-type-tabs::-webkit-scrollbar { display: none; }
.hero .plan-type-tab { min-height: 32px; padding: 4px 12px; border: 0; border-radius: 999px; display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.45); color: var(--md-sys-on-primary-container); font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; flex: none; transition: background 0.15s, color 0.15s; scroll-snap-align: start; -webkit-tap-highlight-color: transparent; }
.hero .plan-type-tab .material-symbols-rounded { font-size: 16px; }
.hero .plan-type-tab.active { background: var(--md-sys-primary); color: var(--md-sys-on-primary); box-shadow: var(--md-sys-elevation-1); }
[data-theme-mode="dark"] .hero .plan-type-tab { background: color-mix(in srgb, var(--md-sys-surface-container-high) 60%, transparent); color: var(--md-sys-on-surface); }
[data-theme-mode="dark"] .hero .plan-type-tab.active { background: var(--md-sys-primary); color: var(--md-sys-on-primary); }

.ring { width: 108px; height: 108px; border-radius: 50%; border: 0; padding: 0; position: relative; cursor: pointer; display: grid; place-items: center; background: transparent; transition: transform 0.3s var(--md-sys-motion-spring); -webkit-tap-highlight-color: transparent; animation: ring-breathe 5.4s var(--md-sys-motion-emphasized) infinite; }
.ring-diet { animation-delay: 0.6s; }
.ring:hover { transform: scale(1.04); }
.ring:active { transform: scale(0.97); }
.ring b { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; line-height: 1; color: var(--md-sys-on-primary-container); }
.ring small { font-size: 9px; font-weight: 800; color: var(--md-sys-on-surface-variant); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.ring em { font-size: 10px; font-style: normal; font-weight: 600; color: var(--md-sys-on-surface-variant); margin-top: 1px; white-space: nowrap; }
.ring > div { position: relative; z-index: 1; display: grid; justify-items: center; }
.ring::before { content: ''; position: absolute; inset: 0; border-radius: 50%; padding: 8px; -webkit-mask: linear-gradient(#000,#000) content-box, linear-gradient(#000,#000); mask: linear-gradient(#000,#000) content-box, linear-gradient(#000,#000); -webkit-mask-composite: xor; mask-composite: exclude; }
.ring::before { transition: --plan-progress .8s var(--md-sys-motion-emphasized), --pro-stop .8s var(--md-sys-motion-emphasized), --carb-stop .8s var(--md-sys-motion-emphasized), --fat-stop .8s var(--md-sys-motion-emphasized), background .6s var(--md-sys-motion-emphasized); }
.ring::after { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: rgba(255,255,255,0.6); backdrop-filter: blur(12px) saturate(155%); -webkit-backdrop-filter: blur(12px) saturate(155%); box-shadow: inset 0 1px 1px rgba(255,255,255,0.95), inset 0 -1px 2px rgba(0,29,54,0.06); }
[data-theme-mode="dark"] .ring::after,
[data-theme-mode="auto"] .ring::after { background: color-mix(in srgb, var(--md-sys-surface-container-high) 62%, transparent); box-shadow: inset 0 1px 1px color-mix(in srgb, var(--md-sys-on-surface) 10%, transparent); }
[data-theme-mode="dark"] .ring b,
[data-theme-mode="auto"] .ring b { color: var(--md-sys-on-primary-container); }
[data-theme-mode="dark"] .ring small,
[data-theme-mode="auto"] .ring small { color: var(--md-sys-on-surface); opacity: 0.92; }
[data-theme-mode="dark"] .ring em,
[data-theme-mode="auto"] .ring em { color: var(--md-sys-on-surface); opacity: 0.8; }
[data-theme-mode="dark"] .ring-diet b,
[data-theme-mode="auto"] .ring-diet b { color: var(--md-sys-on-surface); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme-mode="light"]) .ring::after { background: color-mix(in srgb, var(--md-sys-surface-container-high) 62%, transparent); box-shadow: inset 0 1px 1px color-mix(in srgb, var(--md-sys-on-surface) 10%, transparent); }
    :root:not([data-theme-mode="light"]) .ring b { color: var(--md-sys-on-primary-container); }
    :root:not([data-theme-mode="light"]) .ring-diet b { color: var(--md-sys-on-surface); }
    :root:not([data-theme-mode="light"]) .ring small { color: var(--md-sys-on-surface); opacity: 0.92; }
    :root:not([data-theme-mode="light"]) .ring em { color: var(--md-sys-on-surface); opacity: 0.8; }
}
.ring-train::before { background: conic-gradient(from -90deg, var(--md-sys-primary) 0deg var(--plan-progress, 0deg), color-mix(in srgb, var(--md-sys-primary) 18%, var(--md-sys-surface-container-highest)) var(--plan-progress, 0deg) 360deg); }
.ring-diet::before {
    background: conic-gradient(from -90deg,
        var(--c-pro) 0deg var(--pro-stop, 0deg),
        color-mix(in srgb, var(--md-sys-outline-variant) 40%, var(--md-sys-surface-container-highest)) var(--pro-stop, 0deg) 120deg,
        var(--c-carb) 120deg var(--carb-stop, 120deg),
        color-mix(in srgb, var(--md-sys-outline-variant) 40%, var(--md-sys-surface-container-highest)) var(--carb-stop, 120deg) 240deg,
        var(--c-fat) 240deg var(--fat-stop, 240deg),
        color-mix(in srgb, var(--md-sys-outline-variant) 40%, var(--md-sys-surface-container-highest)) var(--fat-stop, 240deg) 360deg);
}
.ring-diet b { color: var(--md-sys-on-surface); }

.quick-dock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.record-quick-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 4px; border-radius: 20px; background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow-inset); cursor: pointer; transition: transform 0.2s var(--md-sys-motion-spring); -webkit-tap-highlight-color: transparent; }
.record-quick-btn:hover { transform: translateY(-2px); }
.record-quick-btn:active { transform: scale(0.96); }
.record-quick-btn .material-symbols-rounded { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 22px; background: color-mix(in srgb, var(--md-sys-primary-container) 60%, transparent); color: var(--md-sys-on-primary-container); }
.record-quick-btn span:last-child { font-size: 10px; font-weight: 600; color: var(--md-sys-on-surface-variant); }

.plan-card .plan-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.plan-card .pt { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--md-sys-primary); }
.plan-card .pn { font-size: 16px; font-weight: 600; color: var(--md-sys-on-surface); margin-top: 2px; }
.plan-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); font-size: 12px; font-weight: 700; }
.plan-chip .material-symbols-rounded { font-size: 13px; }

.seg-bar { display: flex; gap: 3px; margin-bottom: 10px; }
.seg { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--md-sys-surface-container-highest) 80%, transparent); transition: background 0.3s; }
.seg.done { background: var(--md-sys-primary); }
.seg.cur { background: var(--md-sys-primary); animation: seg-pulse 1.6s ease-in-out infinite; transform-origin: left; }

.plan-meta { display: flex; gap: 12px; font-size: 12px; color: var(--md-sys-on-surface-variant); margin-bottom: 10px; }
.plan-actions { display: flex; align-items: stretch; gap: 8px; min-width: 0; }
.plan-actions .md-btn { flex: 1 1 0; width: auto; height: 44px; margin-top: 0; padding-inline: 10px; }
.plan-actions .md-btn .material-symbols-rounded { flex: none; }

.calorie-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; }
.calorie-head .num { font-size: 32px; font-weight: 600; color: var(--md-sys-primary); letter-spacing: -1px; line-height: 1; }
.calorie-head .unit { font-size: 11px; color: var(--md-sys-on-surface-variant); margin-left: 4px; }
.calorie-head .right { text-align: right; }
.calorie-head .lab { font-size: 10px; color: var(--md-sys-on-surface-variant); }
.calorie-head .val { font-size: 13px; font-weight: 600; color: var(--md-sys-on-surface); }

.stack-bar { display: flex; gap: 3px; height: 12px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--md-sys-surface-container-highest) 80%, transparent); margin-bottom: 10px; }
.stack-bar i { border-radius: 999px; transition: width 0.6s var(--md-sys-motion-emphasized); }
.stack-bar .b1 { background: var(--c-carb); animation: bar-grow 1.2s var(--md-sys-motion-emphasized) both; }
.stack-bar .b2 { background: var(--c-pro); animation: bar-grow 1.2s var(--md-sys-motion-emphasized) 0.1s both; }
.stack-bar .b3 { background: var(--c-fat); animation: bar-grow 1.2s var(--md-sys-motion-emphasized) 0.2s both; }

.macros { display: flex; justify-content: space-between; }
.macro { text-align: center; position: relative; }
.macro small { font-size: 10px; color: var(--md-sys-on-surface-variant); display: block; }
.macro b { font-size: 14px; font-weight: 600; color: var(--md-sys-on-surface); }
.macro::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; vertical-align: middle; margin-right: 4px; background: var(--md-sys-outline-variant); }
.macro.p::before { background: var(--c-pro); }
.macro.c::before { background: var(--c-carb); }
.macro.f::before { background: var(--c-fat); }

.timeline-card { padding: 6px 0 8px; }
.tl-item { display: grid; grid-template-columns: 36px 36px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; }
.tl-time { font-size: 11px; color: var(--md-sys-on-surface-variant); font-weight: 500; text-align: right; }
.tl-dot { width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.tl-dot .material-symbols-rounded { font-size: 18px; }
.tl-item.weight .tl-dot { background: var(--md-sys-secondary-container); color: var(--md-sys-on-secondary-container); }
.tl-item.diet .tl-dot { background: var(--md-sys-tertiary-container); color: var(--md-sys-on-tertiary-container); }
.tl-item.training .tl-dot, .tl-item.now .tl-dot { background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); }
.tl-item.now .tl-dot { background: var(--md-sys-primary); color: var(--md-sys-on-primary); animation: pulse 2s ease-in-out infinite; }
.tl-item.warn .tl-dot { background: var(--md-sys-amber-container, #fff3e0); color: var(--md-sys-on-amber-container, #e65100); }
.tl-item.exercise .tl-dot { background: var(--md-sys-amber-container, #fff3e0); color: var(--md-sys-on-amber-container, #e65100); }
.tl-item.plan .tl-dot { background: color-mix(in srgb, #22c55e 20%, var(--md-sys-surface-container-lowest)); color: #22c55e; }
.tl-body { min-width: 0; }
.tl-title { font-size: 13px; font-weight: 500; color: var(--md-sys-on-surface); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item.now .tl-title { color: var(--md-sys-primary); font-weight: 600; }
.tl-sub { font-size: 11px; color: var(--md-sys-on-surface-variant); }
.tl-tag { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--md-sys-primary); color: var(--md-sys-on-primary); }

.today-ai-reminder { background: linear-gradient(135deg, var(--md-sys-amber-container, #fff3e0), var(--md-sys-surface-container-lowest)); transition: background 0.6s var(--md-sys-motion-emphasized); border-radius: 28px; }
.today-ai-reminder .cardio-kicker { background: var(--glass-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--glass-border); border-radius: 999px; box-shadow: var(--glass-shadow-inset); }

@media (max-width: 380px) {
    .ring { width: 96px; height: 96px; }
    .ring-divider { height: 52px; }
}

}
@layer components {
/* --- V6 Workout (timer-panel V6 / mode-tabs V6 / md-fab V6 / md-field V6 / md-chip V6) --- */

.timer-panel {
    background: linear-gradient(160deg, color-mix(in srgb, var(--md-sys-primary) 90%, #000) 0%, var(--md-sys-primary) 40%, var(--md-sys-primary-container) 100%);
    border-radius: 28px;
    padding: 24px 20px;
    margin-bottom: 12px;
    color: var(--md-sys-on-primary);
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 32px color-mix(in srgb, var(--md-sys-primary) 35%, transparent);
    transition: background 0.6s var(--md-sys-motion-emphasized);
}
.timer-panel:hover {
    box-shadow: 0 12px 32px color-mix(in srgb, var(--md-sys-primary) 35%, transparent),
                inset 0 0 0 9999px rgba(255, 255, 255, 0.05);
}
.timer-panel:active {
    box-shadow: 0 12px 32px color-mix(in srgb, var(--md-sys-primary) 35%, transparent),
                inset 0 0 0 9999px rgba(255, 255, 255, 0.1);
}
.timer-panel:focus { outline: none; }
.timer-panel .timer-tts-btn,
.timer-panel .skip-btn,
.timer-panel .timer-wakelock-btn {
    max-width: calc(100% - 20px);
}
.timer-panel .timer-tts-btn {
    left: 10px;
}
.timer-panel .skip-btn,
.timer-panel .timer-wakelock-btn {
    right: 10px;
}
.timer-panel::before, .timer-panel::after { content: ''; position: absolute; border-radius: 50%; pointer-events: none; }
.timer-panel::before { width: 120px; height: 120px; background: color-mix(in srgb, var(--md-sys-on-primary) 8%, transparent); top: -30px; right: -20px; animation: orb 8s ease-in-out infinite; }
.timer-panel::after { width: 80px; height: 80px; background: color-mix(in srgb, var(--md-sys-on-primary) 6%, transparent); bottom: -20px; left: 20px; animation: orb 10s ease-in-out infinite reverse; }
.status-text,
.timer-panel #statusText { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 3px; opacity: 0.7; color: var(--md-sys-on-primary); }
.main-time,
.timer-panel #mainTime { font-size: clamp(68px, 20vw, 88px); font-weight: 300; letter-spacing: -3px; line-height: 1; margin: 4px 0; color: var(--md-sys-on-primary); text-shadow: 0 2px 12px rgba(0,0,0,0.15); }
.sub-text,
.timer-panel #subText { font-size: 13px; opacity: 0.85; margin-bottom: 12px; color: var(--md-sys-on-primary); }
.timer-stats { display: flex; gap: 8px; background: color-mix(in srgb, var(--md-sys-on-primary) 12%, transparent); border: 1px solid color-mix(in srgb, var(--md-sys-on-primary) 18%, transparent); border-radius: 16px; padding: 10px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.stat-item { flex: 1; text-align: center; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.7; display: block; }
.stat-item b { font-size: 16px; font-weight: 600; }

.mode-tabs { display: flex; background: var(--glass-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--glass-border); border-radius: 999px; padding: 4px; margin-bottom: 12px; }
.mode-tab { flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 6px; border-radius: 999px; border: none; background: transparent; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--md-sys-on-surface-variant); transition: all 0.2s; -webkit-tap-highlight-color: transparent; }
.mode-tab.active { background: var(--md-sys-primary); color: var(--md-sys-on-primary); box-shadow: var(--md-sys-elevation-1); }
.mode-tab .material-symbols-rounded { font-size: 18px; }

.strength-presets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; }
.strength-presets::-webkit-scrollbar { display: none; }
.md-chip { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--glass-border); font-size: 11px; font-weight: 600; color: var(--md-sys-on-primary-container); cursor: pointer; white-space: nowrap; transition: transform 0.15s var(--md-sys-motion-spring); }
.md-chip:active { transform: scale(0.95); }

.md-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.md-field { background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: 12px; padding: 8px 12px; position: relative; }
.md-field.span-full { grid-column: 1 / -1; }
.md-field label { font-size: 10px; font-weight: 600; color: var(--md-sys-on-surface-variant); display: block; margin-bottom: 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-field input,
.md-field select,
.md-field textarea { width: 100%; min-width: 0; border: none; background: transparent; font-size: 14px; font-weight: 500; color: var(--md-sys-on-surface); outline: none; }

.workout-controls { display: inline-flex; justify-content: center; align-items: center; gap: 14px; margin: 12px auto; padding: 10px 16px; border-radius: 999px; background: var(--glass-bg); backdrop-filter: blur(18px) saturate(1.45); -webkit-backdrop-filter: blur(18px) saturate(1.45); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow-inset); }
.md-fab { width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--glass-bg); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--glass-border); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--md-sys-elevation-2); transition: transform 0.2s var(--md-sys-motion-spring); -webkit-tap-highlight-color: transparent; }
.md-fab:active { transform: scale(0.94); }
.fab-play { width: auto; min-width: 132px; height: 56px; border-radius: 28px; background: var(--md-sys-primary); color: var(--md-sys-on-primary); gap: 6px; padding-inline: 18px; font-size: 13px; font-weight: 600; animation: fab-glow 2.5s ease-in-out infinite; }
.fab-play .material-symbols-rounded { flex: none; }
.fab-play .fab-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workout-plan-toolbar,
.strength-presets {
    max-width: 100%;
    contain: inline-size;
}

@media (max-width: 380px) {
    .main-time,
    .timer-panel #mainTime { font-size: 64px; }
    .timer-panel { padding: 20px 16px; }
    .mode-tab { font-size: 11px; gap: 2px; }
    .mode-tab .material-symbols-rounded { font-size: 16px; }
    .workout-controls { gap: 10px; padding-inline: 12px; }
    .fab-play { min-width: 116px; padding-inline: 12px; }
}

}
@layer components {
/* --- V6 Records (record-tabs / stat-tile / cal-grid / swipe-deck) --- */

.record-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--glass-bg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--glass-border); border-radius: 999px; padding: 4px; margin-bottom: 12px; }
.record-tab { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 4px; border-radius: 999px; border: none; background: transparent; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--md-sys-on-surface-variant); transition: all 0.2s; -webkit-tap-highlight-color: transparent; }
.record-tab.active { background: var(--md-sys-primary); color: var(--md-sys-on-primary); }
.record-tab .material-symbols-rounded { font-size: 18px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat-tile { background: var(--glass-bg-strong); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--glass-border); border-radius: 20px; padding: 14px; box-shadow: var(--glass-shadow-inset); position: relative; overflow: hidden; }
.stat-tile .lab { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--md-sys-on-surface-variant); }
.stat-tile .val { font-size: 24px; font-weight: 600; color: var(--md-sys-on-primary-container, var(--md-sys-on-surface)); margin: 4px 0 2px; }
.stat-tile .delta { font-size: 12px; font-weight: 700; color: var(--md-sys-on-surface-variant); display: flex; align-items: center; gap: 2px; }
.stat-tile .delta.is-down { color: #22c55e; }
.stat-tile .delta.is-up { color: var(--md-sys-error, #ef4444); }
.stat-tile .mini-chart { width: 100%; height: 48px; margin-top: 8px; display: block; }
.stat-tile .mini-chart polyline { stroke: var(--md-sys-primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat-tile .mini-chart polygon { fill: color-mix(in srgb, var(--md-sys-primary) 15%, transparent); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-size: 10px; text-align: center; color: var(--md-sys-on-surface-variant); font-weight: 600; }
.cal-day { font-size: 11px; font-weight: 500; text-align: center; padding: 6px; border-radius: 10px; cursor: pointer; transition: background 0.15s; position: relative; -webkit-tap-highlight-color: transparent; }
.cal-day:hover { background: color-mix(in srgb, var(--md-sys-surface-container-highest) 60%, transparent); }
.cal-day.dim { opacity: 0.5; }
.cal-day.has::after { content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--md-sys-primary); }
.cal-day.full { background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); font-weight: 700; }
.cal-day.today {
    box-shadow: inset 0 0 0 2px var(--md-sys-primary);
    outline: none;
}
.cal-day.today.full {
    box-shadow: inset 0 0 0 2px var(--md-sys-on-primary-container);
}
.cal-day.selected { background: var(--md-sys-primary-container); border-color: var(--md-sys-primary); box-shadow: 0 0 0 2px var(--md-sys-primary-container); }

.health-swipe-deck,
.library-swipe-deck {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: clip;
    contain: inline-size;
}

.health-swipe-page,
.library-swipe-page {
    min-width: 0;
    max-width: 100%;
}

}
@layer components {
/* --- V6 AI Coach (ai-hero / ai-msg / ai-input / advice-v6 / today quick actions tweaks) --- */

.advice-v6-page { display: grid; gap: 12px; min-width: 0; }

.ai-hero {
    background: linear-gradient(135deg, var(--md-sys-amber-container, #fff3e0), color-mix(in srgb, var(--md-sys-primary-container) 60%, #fff));
    border-radius: 28px;
    padding: 20px;
    transition: background 0.6s var(--md-sys-motion-emphasized);
}
.ai-avatar { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, var(--md-sys-primary), var(--md-sys-tertiary)); display: inline-flex; align-items: center; justify-content: center; color: var(--md-sys-on-primary); font-size: 24px; margin-bottom: 12px; animation: ai-breath 3s ease-in-out infinite; box-shadow: 0 6px 18px color-mix(in srgb, var(--md-sys-primary) 35%, transparent); }
.ai-hero h2 { font-size: 18px; font-weight: 600; color: var(--md-sys-on-surface); margin: 0 0 6px; }
.ai-hero p { font-size: 12px; color: var(--md-sys-on-surface-variant); line-height: 1.5; margin: 0; }
.advice-v6-filter-bar { margin-top: -2px; }
.advice-v6-filter-bar .advice-filter-row { padding: 0; }

.ai-msg-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.ai-msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 12px; line-height: 1.5; }
.ai-msg.user { background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); margin-left: auto; border-bottom-right-radius: 4px; }
.ai-msg.ai { background: var(--glass-bg-strong); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--glass-border); color: var(--md-sys-on-surface); margin-right: auto; border-bottom-left-radius: 4px; box-shadow: var(--glass-shadow-inset); }
[data-theme-mode="dark"] .ai-msg.ai { background: var(--glass-bg); }
.ai-msg.ai.typing::after { content: ''; display: inline-block; width: 20px; text-align: left; animation: typing 1.4s infinite; }
.advice-v6-page .advice-date-group,
.advice-v6-page .advice-date-content,
.advice-v6-page .advice-bubble,
.advice-v6-page .advice-bubble-head,
.advice-v6-page .advice-bubble-content,
.advice-v6-page .advice-version-switcher,
.advice-v6-page .advice-routine-actions,
.advice-v6-page .advice-bubble-actions {
    min-width: 0;
}
.advice-v6-page .advice-date-head,
.advice-v6-page .advice-bubble b,
.advice-v6-page .advice-bubble b small,
.advice-v6-page .advice-bubble-content,
.advice-v6-page .advice-bubble-content p,
.advice-v6-page .advice-bubble-content li,
.advice-v6-page .advice-bubble-actions button {
    overflow-wrap: anywhere;
}
.advice-v6-page .advice-date-head strong,
.advice-v6-page .advice-date-head small,
.advice-v6-page .advice-bubble b small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.advice-v6-page .advice-bubble {
    max-width: min(96%, 340px);
    font-size: 12px;
    line-height: 1.5;
}
.advice-v6-page .advice-bubble-content {
    font-size: 12px;
    line-height: 1.5;
}
.advice-v6-page .advice-bubble-content pre {
    max-width: 100%;
}

.advice-v6-suggestions-card { padding: 12px; }
.advice-v6-suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.advice-v6-suggestions button { padding: 8px 12px; border-radius: 12px; background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--glass-border); font-size: 12px; font-weight: 500; color: var(--md-sys-on-surface); cursor: pointer; text-align: left; transition: transform 0.15s var(--md-sys-motion-spring); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.advice-v6-suggestions button:active { transform: scale(0.95); }

.ai-input { display: flex; gap: 6px; align-items: center; background: var(--md-sys-surface-container); padding: 8px 14px max(8px, env(safe-area-inset-bottom)); position: sticky; bottom: 0; z-index: 20; margin: 0 -14px -14px; box-shadow: 0 -10px 24px color-mix(in srgb, var(--md-sys-surface) 84%, transparent); }
.ai-input .advice-model-chip { flex: none; }
.ai-input textarea { flex: 1 1 auto; min-width: 0; border: none; background: transparent; font-size: 13px; color: var(--md-sys-on-surface); outline: none; resize: none; min-height: 24px; max-height: 80px; font-family: inherit; overflow-wrap: anywhere; }
.ai-input textarea::placeholder { color: var(--md-sys-on-surface-variant); }
.ai-send { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--md-sys-primary); color: var(--md-sys-on-primary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--md-sys-elevation-1); transition: transform 0.2s var(--md-sys-motion-spring); flex: none; }
.ai-send:active { transform: scale(0.92); }
.ai-send .material-symbols-rounded { font-size: 18px; }

.quick-dock .record-quick-btn,
#todayQuickActions .record-quick-btn,
#todayQuickActions .context-ai-btn {
    min-height: 70px;
    height: 70px;
}

#todayQuickActions .record-quick-btn .material-symbols-rounded,
#todayQuickActions .context-ai-btn .material-symbols-rounded {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#todayQuickActions .record-quick-btn span:last-child,
#todayQuickActions .context-ai-btn span:last-child {
    min-height: 12px;
    line-height: 1.2;
}

}
@layer components {
/* --- V6 Profile (profile-hero / avatar / setting-row / profile-v6-back) --- */

.profile-hero {
    background: linear-gradient(135deg, color-mix(in srgb, var(--md-sys-primary-container) 95%, var(--md-sys-secondary-container)), var(--md-sys-secondary-container));
    border-radius: 28px;
    padding: 18px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: 14px;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--md-sys-primary) 18%, transparent);
    transition: background 0.6s var(--md-sys-motion-emphasized);
}
[data-theme-mode="dark"] .profile-hero { background: linear-gradient(135deg, color-mix(in srgb, var(--md-sys-primary-container) 30%, var(--md-sys-surface-container)), color-mix(in srgb, var(--md-sys-secondary-container) 20%, var(--md-sys-surface-container-low))); }
.profile-hero-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--md-sys-primary), var(--md-sys-tertiary)); display: inline-flex; align-items: center; justify-content: center; color: var(--md-sys-on-primary); font-size: 28px; font-weight: 600; box-shadow: 0 6px 18px color-mix(in srgb, var(--md-sys-primary) 35%, transparent); flex: none; }
.avatar .material-symbols-rounded { font-size: 30px; }
.profile-info { flex: 1 1 auto; min-width: 0; }
.profile-info h2 { font-size: 18px; font-weight: 600; color: var(--md-sys-on-primary-container); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-info small { display: block; font-size: 11px; color: var(--md-sys-on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 8px 6px; width: 100%; min-width: 0; border-left: 1px solid rgba(255,255,255,0.45); padding-left: 12px; }
.ps-item { text-align: center; min-width: 0; }
.ps-item b { display: block; font-size: clamp(15px, 4.6vw, 18px); font-weight: 600; line-height: 1.12; color: var(--md-sys-on-primary-container); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ps-item small { display: block; margin-top: 2px; font-size: clamp(8px, 2.7vw, 10px); line-height: 1.1; letter-spacing: 0.2px; color: var(--md-sys-on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.setting-list { padding: 0; display: grid; gap: 0; }
.setting-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; cursor: pointer; transition: background 0.15s; }
.setting-row:hover { background: color-mix(in srgb, var(--md-sys-surface-container-highest) 40%, transparent); }
.setting-row .ico { width: 34px; height: 34px; border-radius: 50%; background: var(--md-sys-primary-container); color: var(--md-sys-on-primary-container); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; flex: none; }
.setting-row .copy { flex: 1; min-width: 0; }
.setting-row .copy strong { display: block; font-size: 13px; font-weight: 500; color: var(--md-sys-on-surface); }
.setting-row .copy small { display: block; font-size: 11px; color: var(--md-sys-on-surface-variant); }
.setting-row .arrow { color: var(--md-sys-outline); font-size: 20px; }

.profile-v6-back-row { display: flex; align-items: center; gap: 4px; padding: 4px 0 12px; }
.profile-v6-back-btn { width: 36px; height: 36px; border-radius: 50%; border: none; background: transparent; color: var(--md-sys-on-surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.15s; flex: none; }
.profile-v6-back-btn::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--md-sys-on-surface); opacity: 0; transition: opacity 0.15s; }
.profile-v6-back-btn:hover::after { opacity: 0.08; }
.profile-v6-back-btn:active { transform: scale(0.92); }
.profile-v6-back-btn .material-symbols-rounded { font-size: 22px; position: relative; z-index: 1; }
.profile-v6-back-title { font-size: 18px; font-weight: 600; color: var(--md-sys-on-surface); letter-spacing: -0.2px; }

@media (max-width: 380px) {
    .profile-hero { grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr); gap: 10px; padding: 16px 12px; }
    .profile-hero-main { gap: 8px; }
    .avatar { width: 46px; height: 46px; }
    .avatar .material-symbols-rounded { font-size: 24px; }
    .profile-info h2 { font-size: 16px; }
    .profile-info small { font-size: 10px; }
    .profile-stats { gap: 4px; }
    .profile-stats { padding-left: 8px; }
}

}
@layer components {
/* --- V6 Bottom Navigation Rail --- */

.md-nav-rail { background: color-mix(in srgb, var(--md-sys-surface-container) 80%, transparent); backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%); border-top: 1px solid color-mix(in srgb, var(--md-sys-surface-container-lowest) 50%, transparent); box-shadow: 0 -1px 0 var(--md-sys-outline-variant); }
[data-theme-mode="dark"] .md-nav-rail { background: color-mix(in srgb, var(--md-sys-surface-container-high) 85%, transparent); }
.nav-item .nav-content > .material-symbols-rounded { transition: transform 350ms var(--md-sys-motion-spring), font-variation-settings 350ms var(--md-sys-motion-emphasized); }
.nav-item.active .nav-content > .material-symbols-rounded { transform: translateY(-1px) scale(1.08); width: 54px; border-radius: 18px; background: var(--md-sys-primary-container); }
.nav-item.active .nav-content small { font-weight: 700; color: var(--md-sys-on-secondary-container); }

}
@layer components {
/* --- Weight Report / Chart --- */
.weight-chart-wrap {
    background: var(--md-sys-surface-container-lowest);
    border: 1px solid var(--md-sys-outline-variant);
    border-radius: var(--md-sys-shape-lg);
    padding: 10px;
    --weight-chart-range-start-scale: 1;
    animation: weight-panel-in var(--md-sys-motion-duration-medium) var(--md-sys-motion-emphasized) both;
    overflow: hidden;
}
.weight-section-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.md-icon-btn.weight-report-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--md-sys-on-surface-variant);
    transition: background-color 120ms, color 120ms;
}
.md-icon-btn.weight-report-btn:hover,
.md-icon-btn.weight-report-btn:focus-visible {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.md-icon-btn.weight-report-btn .material-symbols-rounded { font-size: 22px; }
.md-icon-btn.weight-report-btn[data-has-new="true"]::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--md-sys-tertiary, #f5a524);
    box-shadow: 0 0 0 2px var(--md-sys-surface);
}
.weight-section-icon {
    font-size: 26px;
    opacity: .55;
}
.weight-chart-stage {
    transform-origin: center center;
    transition: transform 140ms ease-out;
    will-change: transform;
}

.weight-report-card {
    max-height: min(82vh, 720px);
}
.weight-report-content {
    overflow: auto;
    overscroll-behavior: contain;
    padding: 0 2px 8px;
}
.weight-report-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.weight-report-tabs button {
    border: 0;
    border-radius: var(--md-sys-shape-full, 999px);
    padding: 10px 12px;
    background: var(--md-sys-surface-container-high);
    color: var(--md-sys-on-surface-variant);
    font-weight: 800;
}
.weight-report-tabs button.active {
    background: var(--md-sys-secondary-container);
    color: var(--md-sys-on-secondary-container);
}
.weight-report-empty,
.weight-report-current {
    display: grid;
    gap: 12px;
    padding: 14px;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container-lowest);
    border: 1px solid var(--md-sys-outline-variant);
}
.weight-report-empty {
    place-items: center;
    text-align: center;
}
.weight-report-empty .material-symbols-rounded {
    font-size: 34px;
    color: var(--md-sys-primary);
}
.weight-report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.weight-report-period {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.weight-report-period small,
.weight-report-archive summary small {
    color: var(--md-sys-on-surface-variant);
}
.weight-report-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}
.weight-report-metrics div {
    min-width: 0;
    padding: 10px;
    border-radius: var(--md-sys-shape-md);
    background: var(--md-sys-surface-container);
}
.weight-report-metrics b {
    display: block;
    font-size: 16px;
}
.weight-report-metrics small {
    display: block;
    margin-top: 3px;
    color: var(--md-sys-on-surface-variant);
    font-size: 11px;
}
.weight-report-ai h4 {
    margin: 0 0 6px;
    font-size: 13px;
}
.weight-report-ai p {
    margin: 0 0 6px;
    color: var(--md-sys-on-surface-variant);
    font-size: 13px;
    line-height: 1.45;
}
.weight-report-archive {
    margin-top: 12px;
}
.weight-report-archive summary {
    cursor: pointer;
    font-weight: 800;
    padding: 10px 2px;
}
.weight-report-archive-list {
    display: grid;
    gap: 6px;
}
.weight-report-archive-list button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 0;
    border-radius: var(--md-sys-shape-md);
    padding: 10px;
    background: var(--md-sys-surface-container);
    color: var(--md-sys-on-surface);
}
.weight-report-archive-list span {
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
}
@media (max-width: 520px) {
    .weight-report-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .weight-report-period,
    .weight-report-archive-list button {
        align-items: flex-start;
        flex-direction: column;
    }
}
.weight-chart-wrap.is-pinching .weight-chart-stage {
    transition: none;
}
.weight-chart-wrap.is-zoom-committing .weight-chart-stage,
.weight-chart-wrap.is-zoom-settling .weight-chart-stage {
    transition: transform var(--md-sys-motion-duration-short, 160ms) var(--md-sys-motion-emphasized, cubic-bezier(0.2, 0, 0, 1));
}
.weight-chart-wrap.is-range-zoom,
.weight-empty-chart.weight-chart-node.is-range-zoom {
    animation: none;
    transition: opacity 200ms var(--md-sys-motion-emphasized, cubic-bezier(0.2, 0, 0, 1));
}
.weight-chart-wrap.is-range-zoom .weight-chart-stage,
.weight-empty-chart.weight-chart-node.is-range-zoom {
    transform-origin: center center;
    animation: weight-chart-range-zoom var(--md-sys-motion-duration-medium, 220ms) var(--md-sys-motion-emphasized, cubic-bezier(0.2, 0, 0, 1)) both;
}
.weight-chart-node.is-range-zoom-in {
    --weight-chart-range-start-scale: 1.035;
}
.weight-chart-node.is-range-zoom-out {
    --weight-chart-range-start-scale: 0.965;
}
.weight-chart { width: 100%; height: 150px; overflow: visible; }
.weight-grid-line { stroke: var(--md-sys-outline-variant); stroke-width: 1; fill: none; opacity: 0.7; }
.weight-line { stroke: var(--md-sys-primary); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.weight-dot { fill: var(--md-sys-primary-container); stroke: var(--md-sys-primary); stroke-width: 2; }
.weight-month-line { stroke: var(--md-sys-tertiary); stroke-width: 1; stroke-dasharray: 3 5; opacity: 0.34; }
.weight-month-label {
    fill: var(--md-sys-on-surface-variant);
    font-size: 8px;
    font-weight: 700;
    opacity: 0.72;
}
.weight-dot-label {
    font-size: 10px;
    fill: var(--md-sys-on-surface);
    font-weight: 600;
    pointer-events: none;
}
.weight-dot {
    cursor: pointer;
    transition: r 0.15s;
}
.weight-dot:hover, .weight-dot:active {
    r: 7;
}
.weight-chart-wrap {
    position: relative;
}
.weight-chart-wrap[data-pinch-chart="record"] {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}
.weight-chart-wrap[data-pinch-chart="trend"] {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}
.weight-chart-tip {
    position: absolute;
    top: 6px;
    left: 8px;
    max-width: calc(100% - 16px);
    background: var(--md-sys-surface-container-high, #2a2a2a);
    color: var(--md-sys-on-surface, #fff);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    white-space: normal;
    overflow-wrap: anywhere;
    z-index: 2;
}
.weight-chart-labels,
.weight-analysis,
.weight-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.weight-chart-labels { color: var(--md-sys-on-surface-variant); font-size: 11px; padding: 0 4px; }
.weight-analysis { background: var(--md-sys-surface-container); border-radius: var(--md-sys-shape-lg); padding: 12px; }
.weight-analysis div { display: grid; gap: 2px; }
.weight-analysis b { color: var(--md-sys-primary); }
.weight-analysis small,
.weight-list-item span { color: var(--md-sys-on-surface-variant); font-size: 12px; }
.weight-empty-chart {
    display: grid;
    place-items: center;
    gap: 6px;
    min-height: 120px;
    color: var(--md-sys-on-surface-variant);
    background: var(--md-sys-surface-container);
    border-radius: var(--md-sys-shape-lg);
}
.weight-empty-chart .material-symbols-rounded { font-size: 34px; }
.weight-list { display: grid; gap: 6px; }
.weight-list-item { padding: 8px 10px; border-radius: var(--md-sys-shape-md); background: var(--md-sys-surface-container-lowest); }
.weight-list-item span {
    display: grid;
    gap: 2px;
    min-width: 0;
}
.weight-list-item span small {
    color: var(--md-sys-on-surface-variant);
    overflow-wrap: anywhere;
}
.weight-section-head,
.weight-period-nav,
.weight-month-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.weight-section-head > div {
    min-width: 0;
}
.weight-section-head h3 {
    font-size: 18px;
    line-height: 1.2;
    color: var(--md-sys-on-surface);
}
.weight-section-head small,
.weight-period-nav small,
.weight-month-head small {
    color: var(--md-sys-on-surface-variant);
    font-size: 12px;
}
.weight-section-icon {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    flex: none;
    font-variation-settings: 'FILL' 1;
}
.weight-range-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    border-radius: var(--md-sys-shape-full);
    background: var(--md-sys-surface-container);
    overflow-x: auto;
    scrollbar-width: none;
}
.weight-range-tabs::-webkit-scrollbar { display: none; }
.weight-range {
    border: 0;
    border-radius: var(--md-sys-shape-full);
    min-height: 34px;
    padding: 0 12px;
    color: var(--md-sys-on-surface-variant);
    background: transparent;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    transition:
        transform var(--md-sys-motion-duration-short) var(--md-sys-motion-emphasized),
        background var(--md-sys-motion-duration-short),
        color var(--md-sys-motion-duration-short);
}
.weight-range.active {
    background: var(--md-sys-primary-container);
    color: var(--md-sys-on-primary-container);
    box-shadow: var(--md-sys-elevation-1);
}
.weight-range:active { transform: scale(0.94); }
.weight-period-nav {
    padding: 8px;
    border-radius: var(--md-sys-shape-lg);
    background: var(--md-sys-surface-container);
}
.weight-period-nav > div {
    display: grid;
    gap: 2px;
    text-align: center;
    min-width: 0;
}
.weight-period-btn {
    border: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--md-sys-shape-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--md-sys-surface-container-lowest);
    color: var(--md-sys-on-surface);
    cursor: pointer;
    flex: none;
}
.weight-period-btn:disabled { opacity: 0.38; cursor: default; }
.weight-month-group {
    display: grid;
    gap: 6px;
    padding-top: 2px;
}
.weight-month-head {
    padding: 6px 2px 2px;
    color: var(--md-sys-on-surface);
    font-size: 12px;
    font-weight: 900;
}
.weight-record-empty { min-height: 92px; }
@keyframes weight-panel-in {
    from { opacity: 0; transform: translateX(10px) scale(.99); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes weight-chart-range-zoom {
    from { transform: translate3d(0,0,0) scale(var(--weight-chart-range-start-scale, 1)); }
    to { transform: translate3d(0,0,0) scale(1); }
}

.md-field-has-action input {
    padding-right: 52px;
}

.md-field-has-action input:focus {
    padding-right: 51px;
}
}
@layer components {
/* --- Skeleton (shimmer placeholder) --- */
.skeleton {
    background: linear-gradient(90deg,
        var(--md-sys-surface-container) 0%,
        var(--md-sys-surface-container-high) 50%,
        var(--md-sys-surface-container) 100%);
    background-size: 200% 100%;
    border-radius: var(--md-sys-shape-sm);
    animation: m3e-shimmer 1.4s ease-in-out infinite;
    color: transparent !important;
}
@keyframes m3e-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-line { height: 12px; margin: 6px 0; }

}
@layer components {
/* --- Global Training Progress Bar --- */
.global-training-bar {
    position: fixed; top: 0; left: 0; right: 0; height: 3px;
    background: var(--md-sys-surface-container); z-index: 10000;
    transition: opacity .3s ease;
}
.global-training-bar > span {
    display: block; height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--md-sys-primary), var(--md-sys-tertiary));
    transition: width .42s var(--md-expressive-spring);
}
.global-training-bar.hidden { opacity: 0; pointer-events: none; }

}
@layer components {
/* === M3 Expressive Effects ===
   Design-language level: card-rise + chip-press + token-in keyframes,
   global theme transition envelope, FAB morph + ripple animation.
   Module-specific effects have been moved to their host files:
     - today-focus-ring pulse → 16-history-hero-calendar.css
     - advice-quick-prompts horizontal snap → 46-advice-ai.css
     - list-item / day-detail / today-timeline swipe-open → host modules
     - weekly-summary-card rise → 49-action-history-weekly.css
     - skeleton shimmer → 58-skeleton.css
     - global-training-bar → 59-global-training-bar.css
*/

@keyframes m3e-card-rise {
    from { opacity: 0; transform: translateY(8px) scale(.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.md-card { animation: m3e-card-rise .42s var(--md-expressive-spring) both; }

@keyframes m3e-chip-press {
    0% { transform: scale(1); }
    40% { transform: scale(.92) rotate(-1deg); }
    100% { transform: scale(1); }
}
.md-chip:active, .mode-tab:active, .record-quick-btn:active { animation: m3e-chip-press .35s var(--md-expressive-spring); }

/* TASK-18: FAB morph + ripple on training start */
.md-fab.fab-play {
    overflow: hidden; position: relative;
    transition: border-radius .42s var(--md-expressive-spring),
                transform .42s var(--md-expressive-spring),
                box-shadow .42s var(--md-expressive-spring);
}
body.is-training .md-fab.fab-play {
    border-radius: 28px; transform: scale(1.08);
    box-shadow: 0 10px 28px var(--md-sys-primary-container);
}
.md-fab.fab-play .ripple {
    position: absolute; top: 50%; left: 50%;
    width: 12px; height: 12px; border-radius: 50%;
    background: rgba(255,255,255,.55);
    transform: translate(-50%, -50%) scale(0); pointer-events: none;
    animation: m3e-ripple .55s ease-out forwards;
}
@keyframes m3e-ripple {
    to { transform: translate(-50%, -50%) scale(20); opacity: 0; }
}
.ripple {
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: color-mix(in srgb, currentColor 22%, transparent);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    animation: m3e-ripple .55s ease-out forwards;
    z-index: 0;
}

/* TASK-19: AI advice token-in stream animation */
@keyframes m3e-token-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.m3e-token-in { animation: m3e-token-in .26s var(--md-expressive-spring) both; }

/* TASK-20: Liquid theme switch envelope */
:root {
    transition:
        background-color .6s var(--md-sys-motion-emphasized),
        color .35s ease;
}
.md-card, .md-btn, .md-chip, .md-fab, .nav-item, .calendar-day,
.advice-bubble, .day-detail-item, .list-item,
.glass-card, .hero, .timer-panel, .ai-hero, .profile-hero,
.stat-tile, .record-quick-btn, .mode-tabs, .record-tabs,
.md-field, .ai-msg.ai, .ring::after, .plan-chip, .streak-chip,
.setting-row .ico {
    transition:
        background .6s var(--md-sys-motion-emphasized),
        color .35s ease,
        border-color .35s ease,
        box-shadow .6s var(--md-sys-motion-emphasized);
}

}
@layer components {
/* --- A11y --- */

:focus-visible {
    outline: 2px solid var(--md-sys-primary);
    outline-offset: 2px;
}

.advice-composer-input:focus-visible {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

}
@layer overrides {
/* Migration branch custom overrides live here.
   Keep this file as the queue for branch-only additions that have not yet been
   merged into their host module. Each rule MUST carry a TARGET comment, e.g.

       /* TARGET: 15-components-lists.css */
   /*  .my-rule { ... }

   Currently empty: foldable history-month / weight-history rules have been
   merged back into 15-components-lists.css. */

}
