:root {
    --mm-bg: #f7f7fb;
    --mm-card: #ffffff;
    --mm-border: #eceef5;
    --mm-border-strong: #e4e4eb;
    --mm-border-soft: #f0f0f5;
    --mm-text: #2c2c3e;
    --mm-text-dim: #6c6c80;
    --mm-text-mute: #9a9ab0;
    --mm-ghost: #eceef5;
    --mm-ghost-hover: #dcdfec;
    --mm-overlay: rgba(20, 20, 40, 0.55);
    --mm-shadow: rgba(20, 20, 60, 0.04);
    --mm-header-bg: rgba(247, 247, 251, 0.92);
    --mm-ring-bg: #fef3c7;
    --mm-preset-bg: #fef3c7;
    --mm-preset-hover: #fde68a;
    --mm-preset-text: #b45309;
    --mm-pill-bg: #eef2ff;
    --mm-modal-icon-bg: #d1fae5;
    --mm-input-bg: #ffffff;
    --mm-switch-off: #e4e4eb;
}

html.mm-theme-dark {
    --mm-bg: #0f0f17;
    --mm-card: #1a1a26;
    --mm-border: #262635;
    --mm-border-strong: #33334a;
    --mm-border-soft: #22222f;
    --mm-text: #e8e8f0;
    --mm-text-dim: #a0a0b5;
    --mm-text-mute: #707085;
    --mm-ghost: #262635;
    --mm-ghost-hover: #33334a;
    --mm-overlay: rgba(0, 0, 0, 0.75);
    --mm-shadow: rgba(0, 0, 0, 0.5);
    --mm-header-bg: rgba(15, 15, 23, 0.92);
    --mm-ring-bg: #3a2c0a;
    --mm-preset-bg: #3a2c0a;
    --mm-preset-hover: #4d3a10;
    --mm-preset-text: #fbbf24;
    --mm-pill-bg: #252548;
    --mm-modal-icon-bg: #0a3024;
    --mm-input-bg: #25253a;
    --mm-switch-off: #3a3a4a;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    -webkit-tap-highlight-color: transparent;
    background: var(--mm-bg);
    color: var(--mm-text);
    transition: background 0.25s ease, color 0.25s ease;
}

.mm-app {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: 40px;
}

.mm-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--mm-header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--mm-border);
}
.mm-back, .mm-icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mm-text);
    font-size: 22px;
    text-decoration: none;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}
.mm-back:hover, .mm-icon-btn:hover { background: var(--mm-ghost); }
.mm-title {
    font-size: 17px;
    font-weight: 600;
}

.mm-main {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mm-card {
    background: var(--mm-card);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 2px 8px var(--mm-shadow);
    transition: background 0.25s ease;
}

.mm-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--mm-text-dim);
    margin-bottom: 16px;
}
.mm-card-outdoor .mm-card-head i { color: #f59e0b; }
.mm-card-nearwork .mm-card-head i { color: #818cf8; }
.mm-card-history .mm-card-head i { color: #10b981; }

/* Outdoor ring */
.mm-ring-wrap {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 8px auto 20px;
}
.mm-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.mm-ring-bg {
    fill: none;
    stroke: var(--mm-ring-bg);
    stroke-width: 10;
}
.mm-ring-fg {
    fill: none;
    stroke: #f59e0b;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
}
.mm-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.mm-ring-value {
    font-size: 40px;
    font-weight: 700;
    color: #f59e0b;
    line-height: 1;
}
.mm-ring-value .mm-ring-unit {
    font-size: 14px;
    font-weight: 500;
    color: var(--mm-text-dim);
    margin-left: 4px;
}
.mm-ring-goal {
    margin-top: 6px;
    font-size: 13px;
    color: var(--mm-text-mute);
}

/* Near-work */
.mm-nw-big {
    text-align: center;
    padding: 12px 0 20px;
}
.mm-nw-elapsed {
    font-size: 54px;
    font-weight: 700;
    color: #818cf8;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.mm-nw-sub {
    margin-top: 10px;
    font-size: 13px;
    color: var(--mm-text-dim);
}
.mm-nw-next {
    margin-top: 8px;
    display: inline-block;
    padding: 5px 12px;
    background: var(--mm-pill-bg);
    color: #818cf8;
    border-radius: 999px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

/* Actions */
.mm-actions {
    display: flex;
    gap: 10px;
}
.mm-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
    font-family: inherit;
    color: #fff;
}
.mm-btn:active { transform: scale(0.97); }
.mm-btn-primary {
    color: #fff;
    background: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}
.mm-btn-orange { background: #f59e0b; box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25); }
.mm-btn-blue   { background: #6366f1; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25); }
.mm-btn-green  { background: #10b981; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25); }
.mm-btn-ghost {
    background: var(--mm-ghost);
    color: var(--mm-text);
    box-shadow: none;
}
.mm-btn-ghost:hover { background: var(--mm-ghost-hover); }
.mm-btn-danger { color: #e11d48; }
.mm-btn-block { width: 100%; }
.mm-btn-active { background: #e11d48 !important; box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25) !important; }

/* 7-day chart */
.mm-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 6px;
    height: 100px;
    padding: 8px 0 0;
}
.mm-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.mm-chart-bars {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    min-height: 70px;
}
.mm-chart-bar {
    flex: 1;
    max-width: 10px;
    border-radius: 3px 3px 0 0;
    transition: height 0.4s ease;
    min-height: 2px;
}
.mm-chart-bar-outdoor { background: #f59e0b; }
.mm-chart-bar-near { background: #818cf8; }
.mm-chart-lbl {
    font-size: 11px;
    color: var(--mm-text-mute);
    font-variant-numeric: tabular-nums;
}
.mm-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 12px;
    font-size: 12px;
    color: var(--mm-text-dim);
}
.mm-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.mm-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}
.mm-dot-outdoor { background: #f59e0b; }
.mm-dot-near    { background: #818cf8; }

.mm-tip {
    margin: 8px 4px 0;
    padding: 10px 14px;
    font-size: 12px;
    color: var(--mm-text-mute);
    background: var(--mm-card);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.25s ease;
}

/* Overlays */
.mm-overlay {
    position: fixed;
    inset: 0;
    background: var(--mm-overlay);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    animation: mmFadeIn 0.2s ease;
}
.mm-overlay.active {
    display: flex;
}
@media (min-width: 560px) {
    .mm-overlay.active { align-items: center; }
}
@keyframes mmFadeIn { from { opacity: 0; } to { opacity: 1; } }

.mm-modal {
    width: 100%;
    max-width: 420px;
    background: var(--mm-card);
    color: var(--mm-text);
    border-radius: 20px;
    padding: 24px 20px 20px;
    animation: mmSlideUp 0.25s ease;
}
@keyframes mmSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.mm-modal h2 {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 700;
    text-align: center;
}
.mm-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.mm-modal-head h2 {
    margin: 0;
    text-align: left;
    flex: 1;
}
.mm-theme-pill {
    display: inline-flex;
    background: var(--mm-ghost);
    padding: 3px;
    border-radius: 999px;
    gap: 2px;
    flex-shrink: 0;
}
.mm-theme-pill button {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--mm-text-mute);
    cursor: pointer;
    font-size: 15px;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.mm-theme-pill button:active { transform: scale(0.95); }
.mm-theme-pill button.active {
    background: var(--mm-card);
    color: #f59e0b;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.mm-theme-pill button[data-theme="dark"].active {
    color: #a5b4fc;
}
.mm-modal-sub {
    text-align: center;
    color: var(--mm-text-mute);
    font-size: 13px;
    margin: 0 0 20px;
}
.mm-modal-break {
    text-align: center;
}
.mm-modal-icon {
    width: 68px;
    height: 68px;
    margin: 0 auto 12px;
    background: var(--mm-modal-icon-bg);
    color: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}
.mm-modal-break p {
    color: var(--mm-text-dim);
    font-size: 14px;
    margin: 4px 0 16px;
}
.mm-break-count {
    font-size: 56px;
    font-weight: 700;
    color: #10b981;
    font-variant-numeric: tabular-nums;
    margin-bottom: 20px;
}

/* Add-time modal */
.mm-preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.mm-preset {
    padding: 14px;
    background: var(--mm-preset-bg);
    color: var(--mm-preset-text);
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.mm-preset:active { transform: scale(0.97); }
.mm-preset:hover { background: var(--mm-preset-hover); }
.mm-add-custom {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.mm-add-custom input {
    flex: 1;
    padding: 12px 14px;
    border: 1.5px solid var(--mm-border-strong);
    background: var(--mm-input-bg);
    color: var(--mm-text);
    border-radius: 12px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
}
.mm-add-custom input:focus { border-color: #f59e0b; }
.mm-add-custom .mm-btn { flex: 0 0 auto; padding: 12px 20px; }

/* Settings modal */
.mm-setting {
    padding: 14px 0;
    border-bottom: 1px solid var(--mm-border-soft);
}
.mm-setting:last-child { border-bottom: none; }
.mm-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.mm-setting-label {
    display: block;
    font-size: 14px;
    color: var(--mm-text);
    margin-bottom: 8px;
}
.mm-setting-label small {
    font-size: 11px;
    color: var(--mm-text-mute);
    font-weight: 400;
}
.mm-setting-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--mm-text-mute);
    line-height: 1.5;
}
.mm-setting-row .mm-setting-label { margin-bottom: 0; }
.mm-setting input[type=range] {
    width: 100%;
    accent-color: #6366f1;
}

.mm-toggle {
    display: flex;
    background: var(--mm-ghost);
    padding: 4px;
    border-radius: 10px;
    gap: 4px;
}
.mm-toggle button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--mm-text-dim);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}
.mm-toggle button.active {
    background: var(--mm-card);
    color: #6366f1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
html.mm-theme-dark .mm-toggle button.active {
    color: #a5b4fc;
}

/* Switch */
.mm-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}
.mm-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.mm-switch-slider {
    position: absolute;
    inset: 0;
    background: var(--mm-switch-off);
    border-radius: 999px;
    transition: background 0.2s;
}
.mm-switch-slider::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    top: 3px;
    left: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.mm-switch input:checked + .mm-switch-slider { background: #6366f1; }
.mm-switch input:checked + .mm-switch-slider::before { transform: translateX(20px); }

/* ======================== AI 智能看护 ======================== */
.mm-btn-purple { background: #8b5cf6; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25); }

.mm-card-guard { }
.mm-beta {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    color: #fff;
    vertical-align: middle;
}
.mm-guard-intro {
    margin: 8px 4px 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--mm-text-dim);
}

/* 全屏 overlay */
.mm-overlay-full {
    background: var(--mm-bg);
    padding: 0;
}
.mm-overlay-full.active {
    align-items: stretch;
    justify-content: stretch;
}
@media (min-width: 560px) {
    .mm-overlay-full.active { align-items: stretch; }
}

.eg-app {
    flex: 1;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 40px;
    position: relative;
}

.eg-top {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--mm-header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--mm-border);
}
.eg-exit {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--mm-ghost);
    color: var(--mm-text);
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.eg-top-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--mm-text);
}
.eg-top-spacer { width: 36px; }

.eg-screen {
    padding: 20px 16px;
}
.eg-step-icon {
    width: 64px;
    height: 64px;
    margin: 12px auto 16px;
    background: var(--mm-modal-icon-bg);
    color: #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}
.eg-screen h2 {
    text-align: center;
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--mm-text);
}
.eg-desc {
    text-align: center;
    margin: 0 auto 24px;
    max-width: 360px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--mm-text-dim);
}

/* 录音卡 */
.eg-rec-card {
    background: var(--mm-card);
    border: 1px solid var(--mm-border);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 2px 12px var(--mm-shadow);
}
.eg-rec-time {
    font-size: 28px;
    font-weight: 700;
    color: var(--mm-text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}
.eg-rec-hint {
    margin: 6px 0 18px;
    font-size: 13px;
    color: var(--mm-text-dim);
}
.eg-rec-btn {
    width: 72px;
    height: 72px;
    border: none;
    border-radius: 50%;
    background: #8b5cf6;
    color: #fff;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
    transition: transform 0.1s, box-shadow 0.2s;
}
.eg-rec-btn:active { transform: scale(0.95); }
.eg-rec-btn.recording {
    background: #ef4444;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    animation: eg-pulse 1.2s ease-in-out infinite;
}
@keyframes eg-pulse {
    0%, 100% { box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 6px 28px rgba(239, 68, 68, 0.7); }
}
.eg-rec-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: center;
}
.eg-rec-row .mm-btn {
    flex: 1;
    max-width: 140px;
    padding: 10px 12px;
    font-size: 14px;
}

/* 准备屏设置 */
.eg-setting {
    margin-bottom: 20px;
}
.eg-tip {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 12px 14px;
    background: var(--mm-pill-bg);
    border-radius: 12px;
    font-size: 13px;
    color: var(--mm-text-dim);
    line-height: 1.6;
    margin: 20px 0;
}
.eg-tip i { flex-shrink: 0; margin-top: 2px; }

/* 运行屏 */
.eg-video-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 16px;
}
#egVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.eg-video-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.eg-stats {
    background: var(--mm-card);
    border: 1px solid var(--mm-border);
    border-radius: 16px;
    padding: 18px;
    text-align: center;
    margin-bottom: 12px;
}
.eg-stat-label {
    font-size: 13px;
    color: var(--mm-text-dim);
    margin-bottom: 4px;
}
.eg-stat-big {
    font-size: 48px;
    font-weight: 800;
    color: var(--mm-text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    line-height: 1.1;
}
.eg-stat-sub {
    font-size: 13px;
    color: var(--mm-text-mute);
    margin-top: 2px;
}
.eg-stat-progress {
    height: 6px;
    background: var(--mm-ghost);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}
.eg-stat-progress-fg {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #8b5cf6, #ec4899);
    transition: width 0.4s ease;
}

.eg-latest {
    background: var(--mm-card);
    border: 1px solid var(--mm-border);
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 12px;
}
.eg-latest-label {
    font-size: 12px;
    color: var(--mm-text-mute);
    margin-bottom: 4px;
}
.eg-latest-activity {
    font-size: 15px;
    color: var(--mm-text);
    line-height: 1.4;
}
.eg-latest-time {
    font-size: 12px;
    color: var(--mm-text-mute);
    margin-top: 4px;
}

.eg-log-wrap {
    background: var(--mm-card);
    border: 1px solid var(--mm-border);
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 16px;
    max-height: 220px;
    overflow-y: auto;
}
.eg-log-head {
    font-size: 12px;
    color: var(--mm-text-mute);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.eg-log-item {
    font-size: 13px;
    color: var(--mm-text);
    line-height: 1.5;
    padding: 4px 0;
    border-bottom: 1px solid var(--mm-border-soft);
}
.eg-log-item:last-child { border-bottom: none; }
.eg-log-time {
    display: inline-block;
    min-width: 60px;
    color: var(--mm-text-mute);
    font-variant-numeric: tabular-nums;
    margin-right: 6px;
}
.eg-log-err { color: #ef4444; }

/* 休息提醒全屏遮罩 */
.eg-alert {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: linear-gradient(160deg, #8b5cf6, #ec4899);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
}
.eg-alert-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    margin-bottom: 24px;
    animation: eg-bob 2.5s ease-in-out infinite;
}
@keyframes eg-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.eg-alert h1 {
    font-size: 32px;
    margin: 0 0 12px;
    font-weight: 800;
}
.eg-alert p {
    font-size: 16px;
    margin: 4px 0;
    opacity: 0.92;
}
.eg-alert-play {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    margin-top: 20px !important;
    font-size: 14px !important;
    opacity: 0.85 !important;
}
