:root{
  --bg:#f3f4f9;--surface:#ffffff;--surface2:#eef0f7;--surface3:#e5e8f2;
  --text:#181a20;--muted:#6b7280;--muted2:#9aa1af;
  --primary:#4f46e5;--primary-d:#4338ca;--on-primary:#ffffff;--primary-tint:#eceafd;
  --green:#12855a;--greenbg:#dcf7ea;
  --orange:#b8650c;--orangebg:#fff1de;
  --red:#d0303f;--redbg:#ffe4e7;
  --border:#e5e7f0;--divider:#eceef5;
  --shadow-1:0 1px 3px rgba(20,24,40,.08),0 1px 2px rgba(20,24,40,.06);
  --shadow-2:0 4px 14px rgba(20,24,40,.10),0 2px 4px rgba(20,24,40,.06);
  --shadow-3:0 10px 30px rgba(20,24,40,.16),0 4px 10px rgba(20,24,40,.08);
  --scrim:rgba(10,12,20,.5);
  --ripple:rgba(20,24,40,.10);
  color-scheme:light;
}
:root[data-theme="dark"]{
  --bg:#101218;--surface:#181b22;--surface2:#20242e;--surface3:#282d3a;
  --text:#eef0f6;--muted:#a2a8b8;--muted2:#767d8f;
  --primary:#7c74f5;--primary-d:#948dff;--on-primary:#12121a;--primary-tint:#242244;
  --green:#4fd399;--greenbg:#173629;
  --orange:#ffb15c;--orangebg:#3a2a14;
  --red:#ff8189;--redbg:#3a191d;
  --border:#2a2e3a;--divider:#22252f;
  --shadow-1:0 1px 3px rgba(0,0,0,.4),0 1px 2px rgba(0,0,0,.3);
  --shadow-2:0 4px 14px rgba(0,0,0,.45),0 2px 4px rgba(0,0,0,.3);
  --shadow-3:0 10px 30px rgba(0,0,0,.55),0 4px 10px rgba(0,0,0,.35);
  --scrim:rgba(0,0,0,.6);
  --ripple:rgba(255,255,255,.10);
  color-scheme:dark;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font:15px/1.45 "Roboto",system-ui,-apple-system,"Segoe UI",sans-serif;transition:background .25s ease,color .25s ease}
button,input,select,textarea{font:inherit;color:inherit}
button{-webkit-user-select:none;user-select:none}
.app{max-width:560px;margin:auto;min-height:100dvh;display:flex;flex-direction:column;position:relative}

.ripple-host{position:relative;overflow:hidden}
.ripple{position:absolute;border-radius:50%;background:var(--ripple);transform:scale(0);animation:rip .55s ease-out;pointer-events:none}
@keyframes rip{to{transform:scale(2.6);opacity:0}}

header{height:60px;padding:0 8px 0 14px;display:flex;align-items:center;justify-content:space-between;background:var(--surface);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:20;gap:8px}
.brand{display:flex;align-items:center;gap:9px;font-weight:800;font-size:16.5px;letter-spacing:-.01em;cursor:pointer;min-width:0;flex:1}
.logo{width:32px;height:32px;border-radius:10px;background:var(--primary);color:var(--on-primary);display:grid;place-items:center;font-size:16px;flex-shrink:0}
.brandtext{min-width:0}
.brandname{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brandsub{font-size:10.5px;color:var(--muted);font-weight:600;display:flex;align-items:center;gap:3px}
.headicons{display:flex;align-items:center;gap:2px;flex-shrink:0}
.iconbtn{border:0;background:transparent;width:38px;height:38px;border-radius:50%;cursor:pointer;display:grid;place-items:center;font-size:16px;color:var(--text);position:relative;flex-shrink:0}
.iconbtn:active{background:var(--surface2)}
.installbtn{background:var(--primary-tint);color:var(--primary);animation:installpulse 2.2s ease-in-out infinite}
.installbtn:active{background:var(--primary-tint)}
@keyframes installpulse{0%,100%{box-shadow:0 0 0 0 rgba(79,70,229,.28)}50%{box-shadow:0 0 0 6px rgba(79,70,229,0)}}

.themeswitch{display:flex;align-items:center;background:var(--surface2);border-radius:20px;padding:3px;gap:2px;position:relative;flex-shrink:0}
.themeswitch button{border:0;background:transparent;width:30px;height:30px;border-radius:50%;display:grid;place-items:center;cursor:pointer;font-size:14px;color:var(--muted);position:relative;z-index:1;transition:color .2s}
.themeswitch button.active{color:var(--on-primary)}
.themeswitch .thumb{position:absolute;top:3px;left:3px;width:30px;height:30px;border-radius:50%;background:var(--primary);transition:transform .25s cubic-bezier(.4,0,.2,1);box-shadow:var(--shadow-1)}

main{flex:1;padding:14px 14px 100px;overflow-anchor:none}
.page{display:none}.page.active{display:block;animation:fadein .2s ease}
@keyframes fadein{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
.pagehead{margin-bottom:14px}
.histgroup{margin-top:18px}
.histheading{font-size:12px;text-transform:uppercase;letter-spacing:.5px;color:var(--muted,#6b7280);margin:0 0 8px 2px}
.title{font-size:24px;font-weight:800;margin:2px 0 3px;letter-spacing:-.01em}
.subtitle{color:var(--muted);font-size:13px}

.stats{display:flex;gap:9px;margin-bottom:16px}
.stat{flex:1;background:var(--surface);border-radius:16px;padding:12px 10px;box-shadow:var(--shadow-1);text-align:left;border-left:3px solid transparent}
.stat.s-run{border-color:var(--primary)}.stat.s-done{border-color:var(--green)}.stat.s-lbl{border-color:var(--orange)}
.stat b{font-size:22px;display:block;line-height:1.1}
.stat span{font-size:11px;color:var(--muted);font-weight:600}

.toolbar{display:flex;gap:8px;margin-bottom:12px}
.searchbox{flex:1;display:flex;align-items:center;gap:8px;background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:0 12px;height:44px}
.searchbox input{border:0;background:transparent;outline:none;flex:1;color:var(--text);font-size:14px}
.searchbox .sicon{color:var(--muted2);font-size:15px}
.filterbtn{width:44px;height:44px;border-radius:14px;background:var(--surface);border:1px solid var(--border);display:grid;place-items:center;cursor:pointer;font-size:15px;position:relative;flex-shrink:0}
.filterbtn.on{background:var(--primary-tint);border-color:var(--primary);color:var(--primary)}
.filterdot{position:absolute;top:6px;right:6px;width:7px;height:7px;border-radius:50%;background:var(--red)}

.chiprow{display:flex;gap:7px;overflow-x:auto;padding-bottom:2px;margin-bottom:14px;scrollbar-width:none}
.chiprow::-webkit-scrollbar{display:none}
.chip{flex-shrink:0;padding:7px 13px;border-radius:20px;background:var(--surface);border:1px solid var(--border);font-size:12.5px;font-weight:600;color:var(--muted);cursor:pointer;white-space:nowrap}
.chip.active{background:var(--primary);color:var(--on-primary);border-color:var(--primary)}

.task{background:var(--surface);border-radius:18px;padding:14px;margin:0 0 11px;box-shadow:var(--shadow-1);border-left:3px solid var(--primary);transition:box-shadow .15s}
.task.complete{border-left-color:var(--green)}
.tasktop{display:flex;justify-content:space-between;gap:10px;align-items:flex-start}
.taskname{font-size:15.5px;font-weight:700;line-height:1.3}
.date{font-size:11.5px;color:var(--muted);margin-top:3px;display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.date .dsep{color:var(--muted2)}
.badge{display:inline-flex;padding:5px 10px;border-radius:20px;background:var(--primary-tint);color:var(--primary);font-size:10.5px;font-weight:700;white-space:nowrap;flex-shrink:0}
.badgerow{display:flex;gap:6px;flex-shrink:0;flex-wrap:wrap;justify-content:flex-end}
.prio{display:inline-flex;align-items:center;gap:4px;padding:5px 10px;border-radius:20px;font-size:10.5px;font-weight:700;white-space:nowrap}
.prio::before{content:'';width:6px;height:6px;border-radius:50%;background:currentColor}
.prio-low{background:var(--surface3);color:var(--muted)}
.prio-medium{background:var(--orangebg);color:var(--orange)}
.prio-high{background:#ffe4c2;color:#b8650c}
:root[data-theme="dark"] .prio-high{background:#3a2810;color:#ffb15c}
.prio-urgent{background:var(--redbg);color:var(--red)}
.tasknote{font-size:12.5px;color:var(--muted);margin-top:6px;line-height:1.4}
.progress{height:6px;background:var(--surface3);border-radius:10px;overflow:hidden;margin:13px 0 6px}
.bar{height:100%;background:var(--primary);border-radius:10px;transition:width .3s ease}
.task.complete .bar{background:var(--green)}
.pct{font-size:10.5px;color:var(--muted);text-align:right;margin-bottom:9px;font-weight:600}
.steps{display:flex;gap:6px;flex-wrap:wrap}
.step{border:1px solid var(--border);background:var(--surface);border-radius:10px;padding:7px 10px;font-size:11px;cursor:pointer;font-weight:600;color:var(--muted);transition:all .15s;position:relative;overflow:hidden}
.step.done{background:var(--greenbg);border-color:var(--green);color:var(--green)}
.step.indep{border-style:dashed}
.step:disabled{opacity:.65;cursor:default}
.actions{display:flex;gap:7px;margin-top:12px}
.smallbtn{flex:1;border:0;border-radius:11px;padding:9px 6px;background:var(--surface2);cursor:pointer;font-size:12px;font-weight:600;color:var(--text);position:relative;overflow:hidden}
.danger{color:var(--red);background:var(--redbg)}
.iconOnly{flex:none;width:38px}

.empty{text-align:center;color:var(--muted);padding:50px 20px}
.empty .emoji{font-size:40px;margin-bottom:10px;opacity:.5}
.empty b{color:var(--text);display:block;margin-bottom:4px;font-size:15px}
.empty div.hint{font-size:13px}

.labelrow{display:flex;gap:8px;margin-bottom:16px}
.labelrow input{flex:1;border:1px solid var(--border);background:var(--surface);border-radius:14px;padding:12px 14px;outline:none}
.primary{border:0;background:var(--primary);color:var(--on-primary);border-radius:14px;padding:0 18px;font-weight:700;cursor:pointer;font-size:14px;position:relative;overflow:hidden}
.primary:active{background:var(--primary-d)}
.labelitem{background:var(--surface);border-radius:16px;padding:13px 14px;display:flex;align-items:center;gap:11px;margin:8px 0;box-shadow:var(--shadow-1)}
.dot{width:10px;height:10px;border-radius:50%;background:var(--primary);flex-shrink:0}
.labelname{flex:1;font-weight:650;font-size:14.5px}
.labelcount{font-size:11px;color:var(--muted);margin-right:2px}
.labelaction{border:0;background:var(--surface2);border-radius:10px;width:34px;height:34px;cursor:pointer;font-size:13px;display:grid;place-items:center;flex-shrink:0}

/* stage manager rows */
.stagerow{background:var(--surface);border-radius:16px;padding:12px 13px;display:flex;align-items:center;gap:9px;margin:8px 0;box-shadow:var(--shadow-1)}
.stagerow input[type=text]{flex:1;border:1px solid var(--border);background:var(--surface2);border-radius:10px;padding:9px 11px;outline:none;font-size:13.5px}
.stagemini{border:0;background:var(--surface2);border-radius:9px;width:32px;height:32px;cursor:pointer;font-size:12px;display:grid;place-items:center;flex-shrink:0}
.indeptoggle{display:flex;align-items:center;gap:5px;font-size:10.5px;color:var(--muted);font-weight:700;flex-shrink:0;cursor:pointer;padding:5px 8px;border-radius:8px;background:var(--surface2)}
.indeptoggle.on{background:var(--primary-tint);color:var(--primary)}

nav{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:min(560px,100%);background:var(--surface);border-top:1px solid var(--border);display:flex;z-index:30;padding:8px 8px calc(6px + env(safe-area-inset-bottom));gap:2px}
nav button{flex:1;border:0;background:transparent;color:var(--muted);border-radius:14px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;cursor:pointer;font-size:10.5px;font-weight:700;padding:7px 0 6px;position:relative}
nav button.active{color:var(--primary)}
nav button.active .navicon{background:var(--primary-tint)}
nav .navicon{font-size:16px;width:44px;height:26px;border-radius:16px;display:grid;place-items:center;transition:background .2s}
.navbadge{position:absolute;top:2px;right:calc(50% - 22px);min-width:15px;height:15px;border-radius:8px;background:var(--red);color:#fff;font-size:9px;font-weight:800;display:grid;place-items:center;padding:0 3px}

.fab{position:fixed;left:50%;transform:translateX(calc(-50%+220px));bottom:calc(84px + env(safe-area-inset-bottom));width:58px;height:58px;border-radius:19px;background:var(--primary);color:var(--on-primary);border:0;font-size:26px;display:grid;place-items:center;box-shadow:var(--shadow-3);cursor:pointer;z-index:25;transition:transform .15s}
.fab:active{transform:translateX(calc(-50%+220px)) scale(.92)}
@media(max-width:559px){.fab{transform:translate(0,0)}.fab:active{transform:scale(.92)}}

.sheetwrap{position:fixed;inset:0;z-index:50;display:none}
.sheetwrap.open{display:block}
.sheetscrim{position:absolute;inset:0;background:var(--scrim);opacity:0;transition:opacity .22s}
.sheetwrap.open .sheetscrim{opacity:1}
.sheet{position:absolute;left:50%;bottom:0;transform:translate(-50%,100%);width:min(560px,100%);max-height:88dvh;overflow-y:auto;background:var(--surface);border-radius:24px 24px 0 0;box-shadow:var(--shadow-3);transition:transform .28s cubic-bezier(.32,.72,0,1);padding-bottom:env(safe-area-inset-bottom)}
.sheetwrap.open .sheet{transform:translate(-50%,0)}
.sheetgrip{width:36px;height:4px;border-radius:3px;background:var(--surface3);margin:10px auto 4px}
.sheetbody{padding:6px 20px 24px}
.sheetbody h2{margin:6px 0 18px;font-size:19px;font-weight:800}
.sheetbody h2 small{display:block;font-size:12px;color:var(--muted);font-weight:600;margin-top:3px}
.field{margin:12px 0}
.field label{font-size:12px;color:var(--muted);display:block;margin-bottom:6px;font-weight:600}
.field input,.field select,.field textarea{width:100%;padding:13px 14px;border:1px solid var(--border);border-radius:13px;background:var(--surface2);color:var(--text);outline:none;font-size:14.5px;resize:none}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--primary)}
.modalactions{display:flex;gap:9px;margin-top:20px}
.modalactions button{flex:1;padding:13px;border-radius:13px;border:0;cursor:pointer;font-weight:700;font-size:14px;position:relative;overflow:hidden}
.cancel{background:var(--surface2);color:var(--text)}

.filtergroup{margin:14px 0}
.filtergroup .flabel{font-size:12px;color:var(--muted);font-weight:700;margin-bottom:8px;letter-spacing:.02em}
.filteropts{display:flex;flex-wrap:wrap;gap:7px}
.fopt{padding:9px 14px;border-radius:20px;background:var(--surface2);border:1px solid var(--border);font-size:13px;font-weight:600;cursor:pointer;color:var(--text)}
.fopt.active{background:var(--primary);border-color:var(--primary);color:var(--on-primary)}

.boarditem{display:flex;align-items:center;gap:11px;padding:13px;border-radius:16px;background:var(--surface2);margin:8px 0;cursor:pointer;border:2px solid transparent}
.boarditem.active{border-color:var(--primary);background:var(--primary-tint)}
.boardicon{width:38px;height:38px;border-radius:12px;background:var(--primary);color:var(--on-primary);display:grid;place-items:center;font-size:16px;flex-shrink:0}
.boardinfo{flex:1;min-width:0}
.boardname{font-weight:700;font-size:14.5px}
.boardmeta{font-size:11.5px;color:var(--muted)}
.tplcard{display:flex;align-items:center;gap:12px;padding:14px;border-radius:16px;background:var(--surface2);margin:8px 0;cursor:pointer;border:1px solid var(--border)}
.tplcard:active{background:var(--surface3)}
.tplicon{font-size:22px;width:40px;text-align:center;flex-shrink:0}
.tplname{font-weight:700;font-size:14.5px}
.tplstages{font-size:11.5px;color:var(--muted);margin-top:2px}

.toast{position:fixed;left:50%;bottom:calc(96px + env(safe-area-inset-bottom));transform:translate(-50%,20px);background:var(--text);color:var(--bg);padding:12px 18px;border-radius:14px;font-size:13.5px;font-weight:600;box-shadow:var(--shadow-3);z-index:60;opacity:0;transition:all .25s;display:flex;align-items:center;gap:14px;max-width:88%}
.toast.show{opacity:1;transform:translate(-50%,0)}
.toast button{border:0;background:transparent;color:var(--primary-d);font-weight:800;cursor:pointer;font-size:13px;flex-shrink:0}
:root[data-theme="dark"] .toast button{color:var(--primary)}

.history .task{opacity:.92}
::-webkit-scrollbar{width:0;height:0}
.backbtn{display:flex;align-items:center;gap:6px;color:var(--primary);font-weight:700;font-size:13px;cursor:pointer;margin-bottom:14px}

/* data backup */
.data-card{margin-top:18px;padding:16px;border:1px solid var(--line,#e5e7eb);border-radius:18px;background:var(--card,#fff)}
.data-head{display:flex;justify-content:space-between;gap:12px;align-items:center}.data-title{font-weight:800;font-size:16px}.data-sub{font-size:12px;color:var(--muted,#6b7280);margin-top:3px}.data-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.data-actions button{flex:1;min-width:130px}

.install-text-btn{background:var(--primary-tint);color:var(--primary);border:0;border-radius:12px;padding:9px 12px;font-weight:800;white-space:nowrap}
