/* ==========================================================
   自律打卡 · style.css v0-1.08
   包含：全局变量、毛玻璃卡片、导航、今日打卡、近3日回顾、
         旬统计、长期统计、设置、弹窗、迁移弹窗、暗色模式
   ========================================================== */

/* ===== 全局变量 ===== */
:root {
    --bg: #f5f7fb;
    --card: rgba(255, 255, 255, 0.78);
    --card-border: rgba(255, 255, 255, 0.35);
    --shadow: 0 12px 32px -10px rgba(0, 20, 30, 0.10);
    --text: #1a2634;
    --text2: #6b7a8f;
    --accent: #4f7cff;
    --accent-soft: #eef3ff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --physio: #f97316;
    --radius: 20px;
    --radius-sm: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --tab-height: 64px;
    --icon-size: 32px;
}

/* ===== 重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 0 14px 80px;
    max-width: 520px;
    margin: 0 auto;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
input, textarea, .summary-area {
    user-select: text;
    -webkit-user-select: text;
}

/* ===== 毛玻璃卡片 ===== */
.glass {
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
    transition: 0.2s;
}

.glass-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text2);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.glass-title .title-right {
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text2);
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ===== 通用按钮 ===== */
.btn {
    padding: 4px 14px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
    background: white;
    color: var(--text);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 500;
    transition: 0.15s;
    font-family: var(--font);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn:hover {
    background: #f1f4f9;
}
.btn-accent {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-accent:hover {
    background: #3b66e0;
}
.btn-sm {
    padding: 2px 10px;
    font-size: 0.65rem;
}
.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: white;
}
.btn-close {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text2);
    opacity: 0.6;
    transition: 0.15s;
    padding: 0 4px;
    line-height: 1;
}
.btn-close:hover {
    opacity: 1;
    color: var(--text);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 0.78rem;
    font-weight: 500;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    max-width: 90%;
    text-align: center;
}
.toast.show {
    opacity: 1;
}

/* ===== 顶部导航栏 ===== */
.header {
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 10px 0 10px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.header-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.header-title .sub {
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text2);
}
.cycle-info {
    font-size: 0.68rem;
    color: var(--text2);
    background: var(--bg);
    padding: 3px 12px;
    border-radius: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
#syncStatus {
    font-size: 0.65rem;
    color: var(--text2);
}
.header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}
.header-actions .btn {
    padding: 2px 10px;
    font-size: 0.65rem;
}
#installBtn {
    font-size: 0.65rem;
    padding: 2px 10px;
    display: inline-flex;
}

/* ===== 底部导航 ===== */
.tab-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-height);
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--card-border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text2);
    font-size: 0.55rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    font-family: var(--font);
    position: relative;
    transition: 0.15s;
    padding: 4px 0;
}
.tab-btn.active {
    color: var(--accent);
    font-weight: 700;
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
}
.tab-btn .icon {
    font-size: 1.1rem;
    line-height: 1.2;
}
.tab-btn .label {
    font-size: 0.5rem;
    line-height: 1.1;
}

/* ===== 面板切换 ===== */
.tab-panel {
    display: none;
    animation: fadeSlide 0.25s ease;
}
.tab-panel.active {
    display: block;
}
@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================
   今日打卡
   ========================================================== */
.day-selector {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.day-chip {
    padding: 5px 12px;
    border-radius: 30px;
    border: 1.5px solid #e2e8f0;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    background: white;
    transition: 0.15s;
    color: var(--text2);
}
.day-chip.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.day-chip.has-data {
    border-color: var(--success);
    background: #ecfdf5;
}
.day-chip.has-data.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.day-chip.today {
    border-color: var(--accent);
    color: var(--accent);
}
.day-chip.today.active {
    color: white;
}

.check-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
@media (max-width: 400px) {
    .check-grid {
        grid-template-columns: 1fr;
    }
}

.check-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.15s;
    position: relative;
}
.check-item.checked {
    background: #d1fae5;
    border-color: #6ee7b7;
}
.check-item.checked-physio {
    background: #ffedd5;
    border-color: #fdba74;
}
.check-item .box {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.55rem;
    transition: 0.15s;
}
.check-item.checked .box {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.check-item.checked-physio .box {
    background: var(--physio);
    border-color: var(--physio);
    color: white;
}
.check-item .label-wrap {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
}
.check-item .label-wrap .display-name {
    font-size: 0.72rem;
    font-weight: 500;
}
.check-item .label-wrap .add-name {
    font-size: 0.6rem;
    color: var(--text2);
    font-weight: 400;
}
.check-item .cat-tag {
    font-size: 0.55rem;
    padding: 1px 4px;
    border-radius: 10px;
    font-weight: 600;
    flex-shrink: 0;
}
.cat-life {
    background: #e0f2fe;
    color: #0369a1;
}
.cat-clean {
    background: #fce7f3;
    color: #9d174d;
}
.cat-physio {
    background: #fef3c7;
    color: #92400e;
}
.cat-study {
    background: #ede9fe;
    color: #5b21b6;
}
.cat-code {
    background: #fee2e2;
    color: #991b1b;
}

.check-item .num-input {
    width: 48px;
    padding: 2px 4px;
    border-radius: 8px;
    border: 1.5px solid #e2e8f0;
    text-align: center;
    font-size: 0.65rem;
    background: white;
    font-family: var(--font);
    flex-shrink: 0;
}

.summary-area {
    width: 100%;
    min-height: 60px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid #e2e8f0;
    font-family: var(--font);
    font-size: 0.78rem;
    resize: vertical;
    background: white;
    color: var(--text);
}

.reorder-indicator {
    font-size: 0.65rem;
    color: var(--accent);
    font-weight: 500;
    padding: 2px 12px;
    background: var(--accent-soft, #eef3ff);
    border-radius: 30px;
    display: none;
    align-items: center;
    gap: 4px;
}
.reorder-indicator.show {
    display: inline-flex;
}

.reorder-mode .check-item {
    cursor: grab;
    padding-left: 6px;
    border-style: dashed;
}
.reorder-mode .check-item:active {
    cursor: grabbing;
}
.reorder-mode .check-item .drag-handle {
    cursor: grab;
    font-size: 0.8rem;
    color: var(--text2);
    padding: 2px 4px;
    user-select: none;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}
.reorder-mode .check-item.drag-over {
    border-color: var(--accent);
    background: var(--accent-soft, #eef3ff);
}
.reorder-mode .check-item.dragging {
    opacity: 0.4;
    border-style: solid;
    border-color: var(--accent);
}
.reorder-mode .check-item .box,
.reorder-mode .check-item .num-input {
    pointer-events: none;
}
.reorder-mode .check-item .label-wrap {
    pointer-events: none;
}

/* ==========================================================
   近3日回顾
   ========================================================== */
.recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}
.recent-header .title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.recent-header h3 {
    font-size: 1rem;
    font-weight: 700;
}
.recent-header .right-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.mode-select {
    padding: 2px 28px 2px 12px;
    font-size: 0.65rem;
    border-radius: 30px;
    border: 1.5px solid #e2e8f0;
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%236b7a8f' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 8px 5px;
}
.mode-select option {
    background: white;
    color: var(--text);
}

.size-btn-wrap {
    position: relative;
}
.size-btn {
    padding: 2px 10px;
    font-size: 0.65rem;
    border-radius: 30px;
    border: 1.5px solid #e2e8f0;
    background: transparent;
    cursor: pointer;
    font-family: var(--font);
}
.size-popup {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 30px;
    padding: 6px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    align-items: center;
    gap: 10px;
    border: 1px solid #e2e8f0;
    z-index: 100;
    white-space: nowrap;
    margin-top: 4px;
}
.size-popup.open {
    display: flex;
}
.size-popup input[type="range"] {
    width: 80px;
    accent-color: var(--accent);
    cursor: pointer;
}
.size-popup span {
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
}

.recent-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.recent-item {
    display: flex;
    gap: 10px;
}
.recent-item .date-marker {
    min-width: 40px;
    text-align: center;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 4px 2px;
    height: fit-content;
}
.recent-item .date-marker .day {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}
.recent-item .date-marker .weekday {
    font-size: 0.5rem;
    color: var(--text2);
    text-transform: uppercase;
}
.recent-item .content {
    flex: 1;
    background: white;
    border-radius: 14px;
    padding: 10px 12px;
    border: 1px solid #f0f2f5;
}
.recent-icon-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.recent-habit-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.recent-habit-icon {
    width: var(--icon-size);
    height: var(--icon-size);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f1f4f9;
    opacity: 0.4;
    transition: 0.15s;
    font-size: calc(var(--icon-size) * 0.55);
    flex-shrink: 0;
}
.recent-habit-icon.done {
    background: #d1fae5;
    opacity: 1;
}
.recent-habit-icon.fail {
    background: #fee2e2;
    opacity: 0.6;
}
.recent-habit-icon.physio-done {
    background: #ffedd5;
    opacity: 1;
}
.recent-habit-icon.physio-fail {
    background: #dbeafe;
    opacity: 0.6;
}

.recent-habit-label {
    font-size: 0.7rem;
    font-weight: 500;
    display: none;
    padding: 2px 6px;
    border-radius: 4px;
}
.recent-habit-label.done {
    background: #d1fae5;
    color: #065f46;
}
.recent-habit-label.fail {
    background: #fee2e2;
    color: #991b1b;
}
.recent-habit-label.physio-done {
    background: #ffedd5;
    color: #92400e;
}
.recent-habit-label.physio-fail {
    background: #dbeafe;
    color: #1e3a8a;
}

.mode-icon .recent-habit-label {
    display: none;
}
.mode-icon .ring-label {
    display: none;
}
.mode-both .recent-habit-label {
    display: inline;
}
.mode-both .ring-label {
    display: flex;
}
.mode-text .recent-habit-icon {
    display: none;
}
.mode-text .recent-habit-label {
    display: inline;
    background: transparent !important;
    padding: 0 2px;
}
.mode-text .recent-habit-label.done {
    color: var(--success);
}
.mode-text .recent-habit-label.fail {
    color: var(--danger);
    opacity: 0.6;
}
.mode-text .recent-habit-label.physio-done {
    color: var(--physio);
}
.mode-text .recent-habit-label.physio-fail {
    color: #3b82f6;
    opacity: 0.6;
}
.mode-text .ring-wrapper {
    display: none;
}
.mode-text .ring-text-only {
    display: inline;
}

.ring-text-only {
    display: none;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text2);
}

.ring-wrapper {
    width: var(--icon-size);
    height: var(--icon-size);
    border-radius: 8px;
    background: #f1f4f9;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ring-inner {
    width: calc(var(--icon-size) * 0.78);
    height: calc(var(--icon-size) * 0.78);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ring-label {
    font-size: calc(var(--icon-size) * 0.3);
    font-weight: 700;
    color: var(--text);
    display: none;
}
.mode-icon .ring-inner {
    font-size: 0;
}
.mode-icon .ring-label {
    display: none;
}
.mode-both .ring-inner {
    font-size: calc(var(--icon-size) * 0.3);
}
.mode-text .ring-wrapper {
    display: none;
}
.mode-text .ring-text-only {
    display: inline;
}

.recent-summary-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 14px;
    padding: 10px 8px;
    margin-top: 8px;
    justify-content: space-around;
    align-items: center;
}
.recent-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 0 auto;
    min-width: 60px;
    text-align: center;
    padding: 4px 0;
    min-height: 52px;
}
.recent-stat-item .stat-main {
    display: flex;
    align-items: baseline;
    gap: 3px;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
}
.recent-stat-item .stat-main .icon {
    font-size: 0.9rem;
}
.recent-stat-item .stat-main .number {
    padding: 0 6px;
    border-radius: 10px;
    display: inline-block;
}
.recent-stat-item .stat-main .number.qualified {
    background: #d1fae5;
    color: #065f46;
}
.recent-stat-item .stat-main .number.unqualified {
    background: #fee2e2;
    color: #991b1b;
}
.recent-stat-item .stat-sub {
    font-size: 0.6rem;
    color: var(--text2);
    line-height: 1.3;
    margin-top: 2px;
}
.recent-stat-item.stat-ring-item {
    flex: 0 0 auto;
    min-height: 52px;
    justify-content: center;
}
.recent-stat-ring {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text);
    flex-shrink: 0;
}

/* ==========================================================
   旬统计
   ========================================================== */
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 0.76rem;
    gap: 8px;
}
.stat-row:last-child {
    border-bottom: none;
}
.stat-row .label {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.stat-row .value {
    font-weight: 600;
    text-align: right;
    font-size: 0.72rem;
    word-break: break-word;
}
.stat-row .value.done {
    color: var(--success);
}
.stat-row .value.fail {
    color: var(--danger);
}

/* F001：达标标记为圆形 ✓/✗（长=高，正圆；含背景色 + 阴影） */
.tag-done {
    background: #10b981;
    color: #fff;
    width: 1.4em; height: 1.4em; padding: 0;
    border-radius: 50%;
    font-size: 0.62rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
    box-shadow: 0 2px 5px rgba(16,185,129,0.35);
}
.tag-fail {
    background: #ef4444;
    color: #fff;
    width: 1.4em; height: 1.4em; padding: 0;
    border-radius: 50%;
    font-size: 0.62rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    vertical-align: middle;
    box-shadow: 0 2px 5px rgba(239,68,68,0.35);
}
/* F002：数值型"累计/日均"行更小、不加粗（比上方天数行小） */
.avg-line {
    font-size: 0.62rem;
    font-weight: 400;
    color: var(--text2);
}
/* F001/F002：日均达标着色（绿=达标 / 橙=不达标≥95% / 红=不达标<95%） */
.avg-ok   { color: #10b981; }
.avg-warn { color: #f59e0b; }
.avg-bad  { color: #ef4444; }

.summary-6d {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.73rem;
    margin-top: 4px;
}
.summary-6d .item {
    display: flex;
    gap: 4px;
}
.summary-6d .item .tag {
    font-weight: 600;
    color: var(--text2);
    flex-shrink: 0;
}
.summary-6d .item .text {
    color: var(--text);
}

.daily-summary-item {
    padding: 5px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    display: flex;
    gap: 8px;
    font-size: 0.74rem;
    cursor: pointer;
    transition: 0.15s;
    align-items: center;
}
.daily-summary-item:hover {
    background: rgba(0, 0, 0, 0.02);
    border-radius: 4px;
}
.daily-summary-item .date {
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}
.daily-summary-item .content {
    color: var(--text2);
}

/* ==========================================================
   长期统计
   ========================================================== */
.date-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.date-picker-row label {
    font-weight: 600;
    font-size: 0.78rem;
}
.date-picker-row input {
    padding: 4px 10px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
    font-size: 0.72rem;
    background: white;
    color: var(--text);
}

.chart-controls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.chart-controls select {
    padding: 3px 12px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
    font-size: 0.68rem;
    background: white;
    font-family: var(--font);
}
.chart-container {
    position: relative;
    height: 180px;
    width: 100%;
}

.stats-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.stats-toggle .btn {
    font-size: 0.68rem;
    padding: 3px 14px;
}
.stats-toggle .btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.stats-panel {
    display: none;
}
.stats-panel.active {
    display: block;
}

.history-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.history-controls .btn {
    font-size: 0.62rem;
    padding: 2px 12px;
}
.history-controls .btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.history-cycle-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.history-cycle-card .cycle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    gap: 8px;
}
.history-cycle-card .cycle-header .range {
    font-weight: 600;
    font-size: 0.78rem;
}
.history-cycle-card .cycle-header .badge {
    font-size: 0.55rem;
    background: var(--accent);
    color: white;
    padding: 1px 10px;
    border-radius: 30px;
}
.history-cycle-card .cycle-header .toggle-icon {
    font-size: 0.7rem;
    color: var(--text2);
}
.history-cycle-card .cycle-summary-content {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 0.74rem;
    color: var(--text2);
    line-height: 1.6;
}
.history-cycle-card .cycle-summary-content.open {
    display: block;
}
.history-cycle-card .cycle-summary-content .item {
    display: flex;
    gap: 6px;
}
.history-cycle-card .cycle-summary-content .item .tag {
    font-weight: 600;
    color: var(--text2);
    flex-shrink: 0;
}

/* ==========================================================
   设置页面
   ========================================================== */
.settings-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 10px 0;
}
.settings-section:last-child {
    border-bottom: none;
}
.settings-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text2);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.settings-section-title .arrow {
    transition: 0.2s;
    font-size: 0.6rem;
}
.settings-section-title .arrow.collapsed {
    transform: rotate(-90deg);
}
.settings-section-body {
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.settings-section-body.collapsed {
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    gap: 8px;
    flex-wrap: wrap;
}
.settings-row .label {
    font-size: 0.78rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.settings-row .label .icon {
    font-size: 0.9rem;
}

.pill-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.pill {
    padding: 3px 12px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.6);
    border: 1.5px solid #e2e8f0;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text2);
    transition: 0.15s;
    user-select: none;
}
.pill.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.pill.inactive {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text2);
    border-color: transparent;
}

.switch {
    position: relative;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch .slider {
    position: absolute;
    inset: 0;
    background: #cbd5e1;
    border-radius: 20px;
    transition: 0.2s;
}
.switch .slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}
.switch input:checked+.slider {
    background: var(--accent);
}
.switch input:checked+.slider::before {
    transform: translateX(18px);
}

.settings-input {
    padding: 4px 10px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
    font-size: 0.72rem;
    background: white;
    color: var(--text);
    font-family: var(--font);
}
.settings-input-sm {
    width: 80px;
}
.settings-input-med {
    width: 130px;
}
.settings-select {
    padding: 3px 10px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
    font-size: 0.7rem;
    background: white;
    font-family: var(--font);
}
.settings-hint {
    font-size: 0.62rem;
    color: var(--text2);
    margin-top: 3px;
    line-height: 1.4;
}
.settings-hint.warn {
    color: var(--danger);
}

.habit-manage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    font-size: 0.74rem;
}
.habit-manage-item:last-child {
    border-bottom: none;
}
.habit-manage-item .icon {
    font-size: 1rem;
}
.habit-manage-item .info {
    flex: 1;
}
.habit-manage-item .info .name {
    font-weight: 500;
}
.habit-manage-item .info .sub {
    color: var(--text2);
    font-size: 0.6rem;
}
.habit-manage-item .actions {
    display: flex;
    gap: 4px;
}

/* 讯飞密钥管理列表（F005 多 Key） */
.xfkey-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    font-size: 0.74rem;
}
.xfkey-item:last-child {
    border-bottom: none;
}
.xfkey-item.active {
    background: rgba(16, 185, 129, 0.07);
}
.xfkey-item .switch {
    margin-top: 2px;
}
.xfkey-item .info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.xfkey-item .info .name {
    font-weight: 600;
}
.xfkey-item .info .sub {
    color: var(--text2);
    font-size: 0.62rem;
    line-height: 1.5;
    word-break: break-all;
}
.xfkey-item .info .sub b {
    color: var(--text);
    font-weight: 500;
}
.xfkey-item .info .sub .btn {
    padding: 0 6px;
    font-size: 0.58rem;
    margin-left: 4px;
    vertical-align: middle;
}
.xfkey-item .actions {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.xfkey-item .actions .btn {
    padding: 2px 6px;
    font-size: 0.62rem;
}

.display-mode-select {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.display-mode-select .btn {
    font-size: 0.6rem;
    padding: 2px 10px;
}
.display-mode-select .btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    max-height: 120px;
    overflow-y: auto;
}
.emoji-picker .emoji-opt {
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    transition: 0.15s;
    user-select: none;
}
.emoji-picker .emoji-opt:hover {
    background: var(--card);
    transform: scale(1.2);
}

/* ==========================================================
   弹窗（通用）
   ========================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-overlay.show {
    display: flex;
}
.modal-content {
    background: var(--card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius);
    padding: 20px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--card-border);
}
.modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.modal-content .modal-header h3 {
    font-size: 1rem;
}
.modal-content label {
    font-size: 0.72rem;
    font-weight: 600;
    display: block;
    margin-top: 6px;
}
.modal-content textarea {
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 0.75rem;
    font-family: var(--font);
    background: white;
    resize: vertical;
    min-height: 40px;
}
.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content input[type="color"],
.modal-content select {
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-size: 0.75rem;
    font-family: var(--font);
    background: white;
    color: var(--text);
}
.modal-content .modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* ==========================================================
   迁移弹窗（专用）
   ========================================================== */
#migrateQr {
    display: flex;
    justify-content: center;
    padding: 8px 0;
    background: white;
    border-radius: var(--radius-sm);
}
#migrateQr svg {
    max-width: 100%;
    height: auto;
}

#migrateVideo {
    display: none;
    width: 100%;
    border-radius: 12px;
    background: #000;
    max-height: 200px;
}

#migrateText,
#migrateTextInput {
    width: 100%;
    min-height: 60px;
    font-size: 0.65rem;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    font-family: monospace;
    background: var(--bg);
    color: var(--text);
}

#migrateScanBtn {
    width: 100%;
    margin-top: 6px;
}

/* 迁移弹窗内的 settings-section 复用 */
#migrateModal .settings-section {
    border-bottom: none;
    padding: 0 0 10px 0;
}
#migrateModal .settings-section:last-child {
    padding-bottom: 0;
}
#migrateModal .settings-section-title {
    font-size: 0.7rem;
    margin-bottom: 6px;
}

/* ==========================================================
   暗色模式适配
   ========================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card: rgba(30, 41, 59, 0.78);
        --card-border: rgba(255, 255, 255, 0.06);
        --text: #e2e8f0;
        --text2: #94a3b8;
        --shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.4);
        --accent-soft: #1e293b;
    }

    .day-chip {
        background: #1e293b;
        border-color: #475569;
        color: #94a3b8;
    }
    .day-chip.has-data {
        background: #064e3b;
        border-color: #34d399;
    }
    .day-chip.active {
        background: var(--accent);
        color: white;
        border-color: var(--accent);
    }

    .check-item {
        background: #1e293b;
    }
    .check-item.checked {
        background: #064e3b;
        border-color: #34d399;
    }
    .check-item.checked-physio {
        background: #7c2d12;
        border-color: #fb923c;
    }
    .check-item .num-input {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
    .check-item.checked .box {
        background: var(--success);
        border-color: var(--success);
        color: white;
    }
    .check-item.checked-physio .box {
        background: var(--physio);
        border-color: var(--physio);
        color: white;
    }

    .summary-area {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }

    .btn {
        background: #1e293b;
        border-color: #475569;
        color: #e2e8f0;
    }
    .btn-accent {
        background: var(--accent);
        color: white;
        border-color: var(--accent);
    }
    .btn-accent:hover {
        background: #3b66e0;
    }

    .tab-nav {
        background: var(--card);
        border-top-color: var(--card-border);
    }

    .stat-row {
        border-color: rgba(255, 255, 255, 0.04);
    }
    .summary-6d {
        background: #1e293b;
    }

    .date-picker-row input {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
    .chart-controls select {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
    .header {
        background: var(--card);
        border-bottom-color: var(--card-border);
    }

    .settings-input {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
    .settings-select {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }

    .pill {
        background: rgba(255, 255, 255, 0.06);
        border-color: #475569;
        color: #94a3b8;
    }
    .pill.active {
        background: var(--accent);
        color: white;
        border-color: var(--accent);
    }
    .pill.inactive {
        background: rgba(255, 255, 255, 0.03);
        color: #64748b;
        border-color: transparent;
    }

    .switch .slider {
        background: #475569;
    }

    .modal-content {
        background: var(--card);
    }
    .modal-content textarea {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
    .modal-content input,
    .modal-content select {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }

    .habit-manage-item {
        border-color: rgba(255, 255, 255, 0.04);
    }
    .settings-section {
        border-color: rgba(255, 255, 255, 0.04);
    }
    .history-cycle-card {
        background: #1e293b;
        border-color: rgba(255, 255, 255, 0.04);
    }

    .recent-item .content {
        background: #1e293b;
        border-color: #334155;
    }
    .recent-habit-icon {
        background: #334155;
    }
    .recent-habit-icon.done {
        background: #064e3b;
    }
    .recent-habit-icon.fail {
        background: #7f1d1d;
    }
    .recent-habit-icon.physio-done {
        background: #7c2d12;
    }
    .recent-habit-icon.physio-fail {
        background: #1e3a5f;
    }
    .recent-habit-label.done {
        background: #064e3b;
        color: #6ee7b7;
    }
    .recent-habit-label.fail {
        background: #7f1d1d;
        color: #fca5a5;
    }
    .recent-habit-label.physio-done {
        background: #7c2d12;
        color: #fdba74;
    }
    .recent-habit-label.physio-fail {
        background: #1e3a5f;
        color: #93c5fd;
    }
    .recent-item .date-marker {
        background: rgba(30, 41, 59, 0.6);
    }
    .recent-summary-stats {
        background: rgba(255, 255, 255, 0.02);
    }
    .recent-stat-item .stat-main .number.qualified {
        background: #064e3b;
        color: #6ee7b7;
    }
    .recent-stat-item .stat-main .number.unqualified {
        background: #7f1d1d;
        color: #fca5a5;
    }
    .ring-wrapper {
        background: #334155;
    }
    .size-popup {
        background: #1e293b;
        border-color: #475569;
        color: #e2e8f0;
    }
    .mode-select {
        border-color: #475569;
        color: #94a3b8;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M1 1l3 3 3-3' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    }
    .mode-select option {
        background: #1e293b;
        color: #e2e8f0;
    }
    .size-btn {
        border-color: #475569;
        color: #94a3b8;
    }
    .mode-text .recent-habit-label.done {
        color: #6ee7b7;
    }
    .mode-text .recent-habit-label.fail {
        color: #fca5a5;
    }
    .mode-text .recent-habit-label.physio-done {
        color: #fdba74;
    }
    .mode-text .recent-habit-label.physio-fail {
        color: #93c5fd;
    }

    .cat-life {
        background: #0c4a6e;
        color: #bae6fd;
    }
    .cat-clean {
        background: #701a75;
        color: #f0abfc;
    }
    .cat-physio {
        background: #78350f;
        color: #fde68a;
    }
    .cat-study {
        background: #4c1d95;
        color: #ddd6fe;
    }
    .cat-code {
        background: #7f1d1d;
        color: #fecaca;
    }

    .toast {
        background: #1e293b;
        color: #e2e8f0;
    }

    .emoji-picker {
        background: #1e293b;
        border-color: #334155;
    }
    .emoji-picker .emoji-opt:hover {
        background: #0f172a;
    }

    #migrateQr {
        background: white;
    }
    #migrateText,
    #migrateTextInput {
        background: #0f172a;
        border-color: #475569;
        color: #e2e8f0;
    }
}

/* ===== v7.3 增补：从 v7.1 找回（v7.2 style.css 漏定义但 app.js 在用）===== */
.text-muted { color: var(--text2); font-size: 0.75rem; }
.empty-tip { color: var(--text2); font-size: 0.8rem; text-align: center; padding: 12px 0; }
.cat-manage-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.cat-manage-row .cat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cat-manage-row input[type="text"] { flex: 1; min-width: 60px; }
.cat-manage-row input[type="color"] { width: 36px; height: 28px; border: none; background: none; cursor: pointer; padding: 0; }

/* ===== v7.3 增补：Chart.js 加载失败时的 SVG 回退图表容器 ===== */
.chart-svg-fallback {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.chart-svg-fallback svg { display: block; width: 100%; height: auto; }