:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --text: #1f2328;
    --sub: #6b7280;
    --line: #eceef1;
    --brand: #185FA5;
    --danger: #A32D2D;
    --danger-bg: #FCEBEB;
    --warn: #854F0B;
    --warn-bg: #FAEEDA;
    --ok: #3B6D11;
    --ok-bg: #EAF3DE;
    --gray: #5F5E5A;
    --gray-bg: #F1EFE8;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 14px 60px;
}

/* ---------- 顶栏 ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 12px;
}

.topbar h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.back {
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: var(--text);
    padding: 0 6px 4px 0;
    cursor: pointer;
}

.add-btn {
    border: none;
    padding: 7px 14px;
    border-radius: 18px;
    background: var(--brand);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.topbar-acts {
    display: flex;
    align-items: center;
    gap: 7px;
}

.switch-btn {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--sub);
    font-size: 12px;
    padding: 5px 11px;
    border-radius: 14px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.switch-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

/* ---------- 统计卡 ---------- */
.summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.sum-card {
    display: block;
    width: 100%;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 6px;
    text-align: center;
    font: inherit;
    color: var(--text);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .1s;
}

.sum-card:active {
    transform: scale(.97);
}

.sum-card b {
    display: block;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.5px;
    line-height: 1.3;
    color: var(--tone, var(--text));
}

.sum-card span {
    font-size: 11.5px;
    color: var(--sub);
}

.sum-card.c-todo { --tone: var(--brand); --tone-bg: #E6F1FB; }
.sum-card.c-stuck { --tone: var(--danger); --tone-bg: var(--danger-bg); }
.sum-card.c-due { --tone: var(--warn); --tone-bg: var(--warn-bg); }
.sum-card.c-done { --tone: var(--gray); --tone-bg: var(--gray-bg); }

.sum-card.active {
    background: var(--tone-bg);
    border-color: var(--tone);
}

.sum-card.active span {
    color: var(--tone);
    font-weight: 600;
}

/* ---------- 快速录入 ---------- */
.quick-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.quick-input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
    outline: none;
}

.quick-input:focus {
    border-color: var(--brand);
}

.quick-btn {
    padding: 0 16px;
    border: none;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    font-size: 13.5px;
    cursor: pointer;
    flex: none;
}

.quick-hint {
    font-size: 11.5px;
    color: #9aa1ab;
    margin: 0 2px 10px;
}

/* ---------- 项目标签 ---------- */
.proj-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 6px;
    scrollbar-width: none;
}

.proj-bar::-webkit-scrollbar {
    display: none;
}

.chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--sub);
    font-size: 12.5px;
    padding: 5px 12px;
    border-radius: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.cdot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: 1px;
}

.chip.on {
    background: #E6F1FB;
    border-color: var(--brand);
    color: var(--brand);
    font-weight: 500;
}

.chip em {
    font-style: normal;
    opacity: .65;
    margin-left: 3px;
    font-size: 11.5px;
}

.chip.more {
    color: var(--brand);
    border-style: dashed;
}

/* ---------- 分组 ---------- */
.group-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--sub);
    margin: 14px 2px 7px;
    letter-spacing: .2px;
}

.group-head .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex: none;
}

.group-head .cnt {
    margin-left: auto;
    color: #b0b6bf;
}

.group-head.toggle {
    width: 100%;
    border: none;
    background: transparent;
    padding: 6px 2px;
    margin: 8px 0 7px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.group-head.toggle .cnt {
    color: var(--brand);
}

/* ---------- 卡片 ---------- */
.items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--bar, var(--brand));
    border-radius: 10px;
    padding: 9px 11px;
    transition: background .12s;
}

.card.is-done {
    background: #fbfbfc;
    border-left-color: #c9ccd1;
}

.card-top {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.tick {
    flex: none;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    border: 1.5px solid #cfd4da;
    background: transparent;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: all .12s;
}

.tick:hover {
    border-color: var(--ok);
}

.card.is-done .tick {
    border-color: var(--ok);
    background: var(--ok);
}

.card.is-done .tick::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(42deg);
}

.card-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

/* 项目标签：放在标题前，先看归属再看事项 */
.ptag {
    flex: none;
    font-size: 11px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 4px;
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.5;
}

.card.is-done .card-title {
    color: #9aa1ab;
    text-decoration: line-through;
}

.pin {
    flex: none;
    font-size: 11px;
    color: var(--brand);
}

.pri {
    flex: none;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--gray-bg);
    color: var(--gray);
}

.pri.p0 { background: var(--danger-bg); color: var(--danger); }
.pri.p1 { background: var(--warn-bg); color: var(--warn); }

.due {
    flex: none;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--gray-bg);
    color: var(--gray);
}

.due.soon { background: var(--warn-bg); color: var(--warn); }
.due.over { background: var(--danger-bg); color: var(--danger); }

.card-sub {
    margin-top: 3px;
    margin-left: 24px;
    font-size: 12px;
    color: var(--sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-detail {
    display: none;
    margin: 8px 0 0 24px;
    padding: 8px 10px;
    background: #f7f8fa;
    border-radius: 8px;
    font-size: 12.5px;
    color: #4a5160;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

.card.expanded .card-detail {
    display: block;
}

.card-tools {
    display: none;
    gap: 6px;
    margin: 8px 0 0 24px;
    flex-wrap: wrap;
}

.card.expanded .card-tools {
    display: flex;
}

.tool {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--sub);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 7px;
    cursor: pointer;
}

.tool:hover {
    border-color: #cfd4da;
    color: var(--text);
}

.tool.stuck {
    color: var(--danger);
    border-color: #f0c9c9;
    background: var(--danger-bg);
}

.tool.danger {
    color: var(--danger);
    border-color: transparent;
    background: transparent;
    margin-left: auto;
}

/* ---------- 空态 ---------- */
.empty {
    text-align: center;
    padding: 56px 20px;
}

.empty-emoji {
    font-size: 15px;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 4px;
}

.empty-sub {
    font-size: 12.5px;
    color: var(--sub);
}

/* ---------- 轻提示 ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 70px;
    transform: translateX(-50%) translateY(10px);
    background: rgba(31, 35, 40, .92);
    color: #fff;
    padding: 9px 16px;
    border-radius: 20px;
    font-size: 13px;
    opacity: 0;
    transition: all .2s;
    z-index: 999;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 420px) {
    .sum-card b { font-size: 18px; }
    .quick-hint { display: none; }
}
