:root {
    --primary: #3b6fd4;
    --primary-dark: #2c56ab;
    --danger: #c0392b;
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #1f2733;
    --muted: #6b7684;
    --line: #e4e8ee;
    --warn-bg: #fff4e5;
    --overdue: #c0392b;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
.container { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
.login-container { max-width: 420px; padding-top: 8vh; }
.brand { text-align: center; margin-bottom: 24px; }
.brand-logo {
    display: block;
    width: 72px; height: 72px; margin: 0 auto 12px;
    border-radius: 18px;
    box-shadow: 0 6px 18px rgba(253,36,65,.42);
}
.brand h1 { margin: 0; font-size: 24px; }
.brand-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; padding: 20px; box-shadow: 0 2px 10px rgba(20,40,80,.04);
}
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
    flex: 1; padding: 10px; background: none; border: none; cursor: pointer;
    font-size: 15px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.input {
    width: 100%; padding: 11px 12px; margin-bottom: 10px;
    border: 1px solid var(--line); border-radius: 9px; font-size: 15px;
    background: #fff; color: var(--text);
}
.input:focus { outline: none; border-color: var(--primary); }
.btn {
    padding: 10px 14px; border-radius: 9px; border: 1px solid transparent;
    font-size: 14px; cursor: pointer; font-weight: 600;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--primary); border-color: var(--line); }
.btn-block { width: 100%; margin-top: 4px; }
.form-msg { min-height: 18px; color: var(--danger); font-size: 13px; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
    padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
    background: #fff; color: var(--muted); font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.composer { margin-bottom: 18px; }
.composer-row { display: flex; gap: 8px; }
.composer-row .input { flex: 1; margin-bottom: 10px; }
.composer-row input[type="date"] { flex: 1 1 130px; min-width: 128px; }
.composer-row input[type="time"] { flex: 0 0 108px; min-width: 104px; }
.composer-row select.input { flex: 0 0 96px; }
.composer-row .btn { align-self: flex-start; margin-bottom: 10px; }
.setting-card { margin-bottom: 16px; }
.push-hint-card { margin-bottom: 16px; padding: 12px 16px; background: #eef7ee; border-color: #cfe6cf; }
.push-hint-card.warn { background: var(--warn-bg); border-color: #f0d9b5; }
.push-hint-text { font-size: 13px; color: #2d6a3a; line-height: 1.6; }
.push-hint-card.warn .push-hint-text { color: #8a5a12; }
.setting-card[hidden] { display: none; }
.setting-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.setting-row { display: flex; gap: 8px; align-items: flex-start; }
.setting-row .input { flex: 0 0 160px; margin-bottom: 4px; }
.setting-card .hint { margin: 4px 0 0; }
.time-badge {
    color: var(--primary); font-weight: 700;
    background: #eef3fc; border-radius: 5px; padding: 0 6px;
}
.item.editing { display: flex; align-items: flex-start; }
.edit-fields { flex: 1; min-width: 0; }
.edit-fields > .input { margin-bottom: 8px; }
.group { margin-bottom: 22px; }
.group-title { font-size: 14px; color: var(--muted); font-weight: 600; margin: 0 0 8px 4px; }
.count {
    display: inline-block; background: #e8edf6; color: var(--primary);
    border-radius: 999px; padding: 0 8px; font-size: 12px; margin-left: 4px;
}
.item {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border: 1px solid var(--line); border-radius: 11px;
    padding: 12px 14px; margin-bottom: 8px;
}
.item.done { opacity: .55; }
.item.done .item-title { text-decoration: line-through; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 15px; font-weight: 600; word-break: break-word; }
.item-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 4px; }
.item-actions { display: flex; gap: 4px; }
.icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: var(--primary); cursor: pointer; font-size: 15px;
}
.icon-btn.danger { color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }
#toast {
    position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
    background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 8px;
    font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 480px) {
    .topbar { flex-direction: column; }
    .topbar-actions { justify-content: flex-start; }
    .composer-row { flex-wrap: wrap; }
    .composer-row input[type="date"] { flex: 1 1 120px; }
    .composer-row input[type="time"] { flex: 0 0 104px; }
    .composer-row select.input { flex: 1 1 96px; }
}

/* ===== iPhone 刘海屏安全区：viewport-fit=cover 后必须用 env() 撑开，否则顶部被状态栏遮挡 ===== */
body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}
.topbar { padding-top: 4px; }

/* ===== 重复规则设置区 ===== */
.repeat-panel {
    margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.repeat-row {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.repeat-row[hidden] { display: none; }
.repeat-label { font-size: 13px; color: var(--muted); min-width: 68px; }
.repeat-row .hint { width: 100%; margin: 2px 0 0 68px; }
.hint-inline { font-size: 12px; color: var(--muted); }
.input-mini { width: 76px; margin: 0; }
.input-select { width: auto; min-width: 150px; margin: 0; }
.input-half { flex: 1; min-width: 130px; margin: 0; }
.day-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.day-grid-wide { max-width: 460px; }
.day-chip { position: relative; cursor: pointer; }
.day-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.day-chip span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0 7px;
    border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--text); font-size: 13px; user-select: none;
}
.day-chip input:checked + span {
    background: var(--primary); border-color: var(--primary); color: #fff;
}
.rule-desc { color: var(--primary); }
.preview-box {
    margin-top: 12px; padding: 12px 14px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.preview-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.preview-desc { font-size: 12px; color: var(--primary); min-height: 16px; margin-bottom: 8px; }
.preview-fires { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.fire-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 9px 4px 4px; background: #fff;
    border: 1px solid var(--line); border-radius: 16px; color: var(--text);
    font-variant-numeric: tabular-nums;
}
.fire-no {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 11px;
}
.edit-fields .preview-box { margin-top: 10px; }
/* 日历视角：按周/月规则高亮会提醒的日子，解决列表看不出周期规律的问题 */
.prev-cal { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.prev-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pc-nav {
    border: 1px solid var(--line); background: var(--card); color: var(--text);
    width: 28px; height: 26px; border-radius: 6px; font-size: 16px; line-height: 1; cursor: pointer;
}
.pc-nav:disabled { opacity: .35; cursor: default; }
.pc-title { font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.prev-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.pc-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.pc-cell {
    text-align: center; font-size: 12px; padding: 5px 0; border-radius: 6px;
    font-variant-numeric: tabular-nums; color: var(--text);
}
.pc-blank { visibility: hidden; }
.pc-hit { background: var(--primary); color: #fff; font-weight: 700; }
.pc-today { outline: 1px solid var(--primary-dark); outline-offset: -1px; }
.prev-cal-hint { font-size: 11px; color: var(--muted); margin-top: 8px; text-align: center; }
@media (max-width: 480px) {
    .repeat-label { min-width: 100%; }
    .repeat-row .hint { margin-left: 0; }
    .input-half { min-width: 120px; }
}
