:root{
  --bg:#F6F2EA; --surface:#FFFFFF; --ink:#1F1C18; --muted:#6B6258; --faint:#9A8F82; --line:#E6DED1; --line2:#EFE8DC;
  --soft:#EFE8DC; --accent:#B4472F; --accent-soft:#F6E3DC; --green:#3F6B4A; --green-soft:#E9EFE6;
  --purple:#4D4A7A; --purple-soft:#EAE8F2; --amber:#7A4B07; --amber-soft:#FBEFD9; --amber-line:#EBCF9C;
  --text2:#5E554B; --control-line:#D8D0C4; --circle-line:#C9BFB2; --empty-ink:#B3A89A; --toast-action:#F6C9B9;
  --display:'Rubik', 'Assistant', system-ui, sans-serif; --body:'Assistant', system-ui, sans-serif;
  color-scheme:light;
}
/* Dark: follows the phone setting unless the user picked light, or forced by picking dark. */
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#171513; --surface:#221F1C; --ink:#F2ECE3; --muted:#B5AA9C; --faint:#857B6F; --line:#37322C; --line2:#2C2824;
    --soft:#2A2622; --accent:#D8674C; --accent-soft:#3A2620; --green:#5E9A6C; --green-soft:#1F2B22;
    --purple:#A9A5DA; --purple-soft:#2A2838; --amber:#E8B464; --amber-soft:#33281A; --amber-line:#5A4524;
    --text2:#C9BEB0; --control-line:#4A443D; --circle-line:#5A534B; --empty-ink:#6E655B; --toast-action:#B4472F;
    color-scheme:dark;
  }
}
:root[data-theme="dark"]{
  --bg:#171513; --surface:#221F1C; --ink:#F2ECE3; --muted:#B5AA9C; --faint:#857B6F; --line:#37322C; --line2:#2C2824;
  --soft:#2A2622; --accent:#D8674C; --accent-soft:#3A2620; --green:#5E9A6C; --green-soft:#1F2B22;
  --purple:#A9A5DA; --purple-soft:#2A2838; --amber:#E8B464; --amber-soft:#33281A; --amber-line:#5A4524;
  --text2:#C9BEB0; --control-line:#4A443D; --circle-line:#5A534B; --empty-ink:#6E655B; --toast-action:#B4472F;
  color-scheme:dark;
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--body);font-size:16px;line-height:1.45;-webkit-text-size-adjust:100%}
button,input,textarea,select{font:inherit;color:inherit}
button{cursor:pointer}
a{color:var(--accent)}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
h1,h2,h3{font-family:var(--display);margin:0;text-wrap:balance}
[hidden]{display:none!important}

.app{max-width:480px;margin:0 auto;min-height:100dvh;padding:calc(env(safe-area-inset-top,0px) + 20px) 20px calc(env(safe-area-inset-bottom,0px) + 96px);display:flex;flex-direction:column;gap:20px}
.center-screen{flex:1;display:flex;align-items:center;justify-content:center;min-height:60dvh}
.spinner{width:36px;height:36px;border-radius:50%;border:3px solid var(--line);border-top-color:var(--accent);animation:spin 0.9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spinner{animation-duration:3s}}

.splash-list{display:flex;flex-direction:column;gap:12px;width:180px}
.splash-row{display:flex;align-items:center;gap:10px}
.splash-check{width:20px;height:20px;border-radius:50%;border:2px solid var(--line);flex-shrink:0;position:relative;animation:splash-check 2.1s ease-in-out infinite}
.splash-check::after{content:'';position:absolute;left:50%;top:44%;width:5px;height:9px;border-right:2px solid #fff;border-bottom:2px solid #fff;transform:translate(-50%,-60%) rotate(45deg);opacity:0;animation:splash-tick 2.1s ease-in-out infinite}
.splash-row:nth-child(2) .splash-check{animation-delay:.3s}
.splash-row:nth-child(2) .splash-check::after{animation-delay:.3s}
.splash-row:nth-child(3) .splash-check{animation-delay:.6s}
.splash-row:nth-child(3) .splash-check::after{animation-delay:.6s}
.splash-line{height:9px;border-radius:5px;background:var(--line)}
@keyframes splash-check{0%,10%{background:transparent;border-color:var(--line)}25%,55%{background:var(--accent);border-color:var(--accent)}70%,100%{background:transparent;border-color:var(--line)}}
@keyframes splash-tick{0%,15%{opacity:0}25%,55%{opacity:1}65%,100%{opacity:0}}
@media (prefers-reduced-motion:reduce){.splash-check,.splash-check::after{animation:none}}
.splash-name{direction:ltr;font-family:'Kalam','Rubik',system-ui,sans-serif;font-weight:700;font-size:64px;line-height:1.2;color:var(--ink);display:flex}
.splash-name span{display:inline-block;opacity:0;transform:translateY(14px) scale(.8);animation:splash-letter .45s cubic-bezier(.34,1.56,.64,1) forwards;animation-delay:calc(var(--i) * 110ms)}
.splash-name .hl{color:var(--accent)}
@keyframes splash-letter{to{opacity:1;transform:none}}
@media (prefers-reduced-motion:reduce){.splash-name span{animation:none;opacity:1;transform:none}}

.topbar{display:flex;justify-content:space-between;align-items:center;min-height:44px}
.brand{font-family:'Kalam',var(--display);font-weight:700;font-size:26px;line-height:1.2;direction:ltr}
.brand b{color:var(--accent);font-weight:inherit}
.iconbtn{width:44px;height:44px;border-radius:22px;border:none;background:var(--surface);display:flex;align-items:center;justify-content:center;color:var(--ink);flex-shrink:0}
.iconbtn.ghost{background:transparent;color:var(--muted)}
.muted{color:var(--muted)}
.small{font-size:14px}
.title{display:flex;flex-direction:column;gap:4px}
.title h1{font-size:32px;font-weight:600;line-height:1.15}
.title p{margin:0;font-size:17px;color:var(--muted)}
.label{font-family:var(--display);font-size:14px;font-weight:600;color:var(--muted)}
.stack{display:flex;flex-direction:column;gap:10px}
.stack-s{display:flex;flex-direction:column;gap:6px}
.row{display:flex;align-items:center;gap:12px}
.grow{flex:1;min-width:0}

/* big nav cards (home, capture) */
.navcard{display:flex;align-items:center;gap:16px;width:100%;min-height:96px;padding:18px 20px;border-radius:22px;border:1px solid var(--line);background:var(--surface);text-align:right;color:var(--ink);text-decoration:none}
.navcard.primary{background:var(--accent);border-color:var(--accent);color:#fff;min-height:112px}
.navcard .ico{width:52px;height:52px;flex-shrink:0;border-radius:16px;display:flex;align-items:center;justify-content:center}
.navcard.primary .ico{background:rgba(255,255,255,.18);color:#fff}
.navcard .t{font-family:var(--display);font-weight:600;font-size:19px}
.navcard.primary .t{font-size:21px}
.navcard .s{font-size:15px;color:var(--muted)}
.navcard.primary .s{color:#fff;opacity:.9}
.badge{min-width:30px;height:30px;padding:0 9px;border-radius:15px;background:var(--green);color:#fff;font-family:var(--display);font-weight:600;font-size:15px;display:flex;align-items:center;justify-content:center}
.tone-accent{background:var(--accent-soft);color:var(--accent)}
.tone-green{background:var(--green-soft);color:var(--green)}
.tone-purple{background:var(--purple-soft);color:var(--purple)}
.tone-amber{background:var(--amber-soft);color:var(--amber)}

/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:54px;padding:0 22px;border-radius:27px;border:1px solid var(--line);background:var(--surface);font-family:var(--display);font-weight:600;font-size:16px;color:var(--ink);text-decoration:none}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}
.btn.green{background:var(--green);border-color:var(--green);color:#fff}
.btn.block{width:100%}
.btn[disabled]{opacity:.55;cursor:default}
.btn.small{height:40px;padding:0 16px;font-size:15px;border-radius:20px}
.linkbtn{border:none;background:transparent;color:var(--muted);text-decoration:underline;padding:10px 0;font-size:15px}
.chip{height:40px;padding:0 14px;border-radius:20px;border:1px solid var(--line);background:var(--surface);font-size:15px;white-space:nowrap}
.chip[aria-pressed="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.bottombar{position:fixed;left:0;right:0;bottom:0;padding:12px 20px calc(env(safe-area-inset-bottom,0px) + 14px);background:var(--bg);border-top:1px solid var(--line);display:flex;gap:10px;justify-content:center;z-index:5}
.bottombar > *{max-width:440px}
.bottombar .btn{flex:1}

/* cards & lists */
.card{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:16px;display:flex;flex-direction:column;gap:10px}
.card-head{display:flex;align-items:center;gap:12px}
.typeicon{width:44px;height:44px;flex-shrink:0;border-radius:14px;display:flex;align-items:center;justify-content:center}
.kicker{font-size:12px;font-weight:700;letter-spacing:.03em}
.card-title{font-family:var(--display);font-weight:600;font-size:18px;line-height:1.25}
.divider{height:1px;background:var(--line2)}
.frow{display:flex;align-items:center;gap:12px;min-height:34px;font-size:16px}
.frow .ic{color:var(--faint);display:flex}
.frow small{display:block;font-size:13px;color:var(--muted)}
.guess{font-size:11px;font-weight:700;padding:1px 8px;border-radius:10px;border:1px dashed var(--accent);color:var(--accent);white-space:nowrap}
.select{height:34px;padding:0 10px;border-radius:17px;border:1px solid var(--line);background:var(--bg);font-size:14px}
.warn{background:var(--amber-soft);border:1px solid var(--amber-line);color:var(--amber);border-radius:16px;padding:12px 14px;display:flex;gap:10px;font-size:15px}
.info{background:var(--soft);border-radius:16px;padding:12px 14px;display:flex;gap:10px;align-items:center;font-size:15px;color:var(--text2)}

.check{display:flex;align-items:center;gap:12px;min-height:48px;padding:6px 14px;border-radius:14px;background:var(--surface);border:1px solid var(--line);cursor:pointer}
.check input{position:absolute;opacity:0;width:1px;height:1px}
.check .box{width:24px;height:24px;flex-shrink:0;border-radius:7px;border:2px solid var(--control-line);display:flex;align-items:center;justify-content:center;color:transparent}
.check input:checked + .box{background:var(--green);border-color:var(--green);color:#fff}
.check.sugg input:checked + .box{background:var(--accent);border-color:var(--accent)}
.check input:focus-visible + .box{outline:3px solid var(--accent);outline-offset:2px}

.list{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:2px 16px}
.task{display:flex;align-items:center;gap:14px;min-height:60px;border-top:1px solid var(--line2)}
.task:first-child{border-top:none}
.circle{width:28px;height:28px;flex-shrink:0;border-radius:14px;border:2px solid var(--circle-line);background:transparent;padding:0;display:flex;align-items:center;justify-content:center;color:transparent}
.circle.done{background:var(--green);border-color:var(--green);color:#fff}
.task .body{flex:1;min-width:0;border:none;background:transparent;text-align:right;padding:10px 0;display:flex;flex-direction:column}
.task .body .t{font-size:17px;font-weight:600}
.task .body .s{font-size:14px;color:var(--muted)}
.task .when{font-family:var(--display);font-size:15px;color:var(--text2);direction:ltr;white-space:pre-line;text-align:center;line-height:1.25}
.task.is-done .t{color:var(--faint);text-decoration:line-through;font-weight:400}
.nextup{display:flex;align-items:center;gap:14px;padding:18px;border-radius:22px;background:var(--surface);color:var(--ink);border:2px solid var(--accent)}
.nextup .circle{width:32px;height:32px;border-radius:16px}
.nextup .body{flex:1;border:none;background:transparent;color:var(--ink);text-align:right;padding:0;display:flex;flex-direction:column}
.nextup-time{font-family:var(--display);font-weight:600;font-size:20px;direction:ltr;color:var(--accent)}
.nextup .t{font-family:var(--display);font-weight:600;font-size:19px}
.nextup .s{font-size:15px;color:var(--muted)}

.rowlink{display:flex;align-items:center;gap:14px;min-height:60px;padding:10px 16px;border-radius:18px;background:var(--surface);border:1px solid var(--line);color:var(--ink);text-decoration:none;width:100%;text-align:right}
.rowlink.amber{background:var(--amber-soft);border-color:var(--amber-soft)}
.rowlink .t{flex:1;font-family:var(--display);font-weight:600;font-size:17px}
.rowlink .n{font-family:var(--display);font-weight:600;font-size:17px;color:var(--muted)}

.week{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:6px}
.day{height:72px;border-radius:14px;border:1px solid var(--line);background:var(--surface);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;padding:0;color:var(--ink)}
.day .d{font-size:12px;color:var(--muted)}
.day .n{font-family:var(--display);font-weight:600;font-size:20px}
.day.today{background:var(--ink);border-color:var(--ink);color:var(--bg)}
.day.today .d{color:var(--bg);opacity:.8}
.day.empty{background:transparent;border-color:var(--line2);color:var(--empty-ink)}
.day.empty .n{font-weight:400;font-size:18px}
.tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.tile{text-decoration:none;display:flex;flex-direction:column;gap:8px;padding:14px;border-radius:18px;background:var(--surface);border:1px solid var(--line);text-align:right;color:var(--ink)}
.tile .top{display:flex;justify-content:space-between;align-items:center}
.tile .ic{width:36px;height:36px;border-radius:12px;display:flex;align-items:center;justify-content:center}
.tile .n{font-family:var(--display);font-weight:600;font-size:22px}
.tile .t{font-weight:600;font-size:16px}
.tile .s{font-size:13px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.field{display:flex;flex-direction:column;gap:4px}
.field label{font-size:14px;color:var(--muted)}
.input{height:50px;padding:0 14px;border-radius:14px;border:1px solid var(--line);background:var(--surface);font-size:16px;width:100%}
textarea.input{height:auto;min-height:180px;padding:14px;line-height:1.55;resize:vertical}
.srcchip{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:16px;background:var(--soft);font-size:14px;color:var(--text2)}
.srcchip img{width:44px;height:44px;border-radius:10px;object-fit:cover}
.srcimg{width:100%;border-radius:16px;border:1px solid var(--line)}
.quote{background:var(--soft);border-radius:16px;padding:14px;font-size:15px;line-height:1.55;white-space:pre-wrap}

.sheet-backdrop{position:fixed;inset:0;background:rgba(31,28,24,.45);z-index:20;display:flex;align-items:flex-end;justify-content:center}
.sheet{width:100%;max-width:480px;max-height:92dvh;overflow-y:auto;background:var(--surface);border-radius:28px 28px 0 0;padding:12px 20px calc(env(safe-area-inset-bottom,0px) + 24px);display:flex;flex-direction:column;gap:16px}
.grabber{align-self:center;width:40px;height:5px;border-radius:3px;background:var(--control-line)}
.optgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.opt{height:64px;border-radius:16px;border:1px solid var(--line);background:var(--bg);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}
.opt b{font-size:16px}
.opt span{font-size:13px;color:var(--muted)}

.fbbtn{height:34px;padding:0 12px;border-radius:17px;border:1px solid var(--line);background:var(--surface);color:var(--muted);font-size:13px;display:flex;align-items:center;gap:5px}
.label.amber{color:var(--amber)}
.tabbar{position:fixed;left:0;right:0;bottom:0;z-index:6;display:grid;grid-template-columns:1fr 1fr 1fr;align-items:end;padding:8px 8px calc(env(safe-area-inset-bottom,0px) + 8px);background:var(--surface);border-top:1px solid var(--line)}
.tab{display:flex;flex-direction:column;align-items:center;gap:3px;padding:4px 0;color:var(--faint);text-decoration:none;font-family:var(--display);font-size:12px;font-weight:500}
.tab.on{color:var(--ink);font-weight:600}
.tab-capture .plus{width:52px;height:52px;margin-top:-26px;border-radius:26px;background:var(--accent);color:#fff;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 14px rgba(180,71,47,.35);border:4px solid var(--surface)}
.tab-capture{color:var(--accent)}
.has-tabbar .app{padding-bottom:calc(env(safe-area-inset-bottom,0px) + 110px)}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(env(safe-area-inset-bottom,0px) + 110px);background:var(--ink);color:var(--bg);padding:12px 18px;border-radius:14px;font-size:15px;z-index:30;max-width:90vw;display:flex;align-items:center;gap:14px}
.toast[hidden]{display:none}
.toast-action{border:none;background:transparent;color:var(--toast-action);font:inherit;font-weight:700;padding:4px 2px}
.steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px}
.steps li{display:flex;gap:10px;align-items:center;color:var(--muted)}
.steps li.on{color:var(--ink);font-weight:600}
.dot{width:10px;height:10px;border-radius:5px;background:var(--line)}
.steps li.on .dot{background:var(--accent)}
.empty-state{text-align:center;color:var(--muted);padding:32px 12px;display:flex;flex-direction:column;gap:12px;align-items:center}
.error{color:var(--accent);font-size:15px}
.circles{display:flex;flex-direction:column;gap:8px}
.circle-row{display:flex;align-items:center;gap:12px;min-height:60px;padding:6px 8px 6px 14px;border-radius:18px;background:var(--surface);border:1px solid var(--line);font-size:18px;font-weight:600}
.emo{width:46px;height:46px;flex-shrink:0;border-radius:14px;border:none;background:var(--bg);font-size:24px;line-height:1;display:flex;align-items:center;justify-content:center}
.emo.unsure{outline:2px dashed var(--accent);outline-offset:-2px}
.emojigrid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px}
.emojibtn{height:52px;border-radius:14px;border:1px solid var(--line);background:var(--bg);font-size:26px;line-height:1}
.emoicon{flex-shrink:0;border-radius:12px;background:var(--bg);display:flex;align-items:center;justify-content:center;line-height:1}
.tile .emoicon{background:var(--bg)}
.cal-nav{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.cal-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}
.cal-dow{text-align:center;font-family:var(--display);font-size:12px;color:var(--muted);padding-bottom:4px}
.cal-cell{aspect-ratio:1;border:1px solid var(--line);border-radius:12px;background:var(--surface);display:flex;flex-direction:column;align-items:center;justify-content:flex-start;padding:4px 2px;gap:3px;cursor:pointer}
.cal-cell.empty{border:none;background:transparent;cursor:default}
.cal-cell.today{border-color:var(--accent);border-width:2px}
.cal-num{font-family:var(--display);font-size:13px;font-weight:600}
.cal-bars{display:flex;flex-direction:column;gap:2px;width:100%;padding:0 3px;align-self:stretch}
.cal-bar{height:4px;border-radius:2px;display:block;width:100%}
.cal-more{font-size:9px;color:var(--muted)}
.legend{display:flex;flex-wrap:wrap;gap:10px 16px;margin-top:6px}
.legend-item{display:flex;align-items:center;gap:6px}
.legend-bar{width:18px;height:4px;border-radius:2px;display:inline-block}
.legend-label{font-size:13px;color:var(--muted)}
.section-title{font-size:15px;font-weight:600;color:var(--muted);margin-top:8px}
.opt[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--bg)}
.opt[aria-pressed="true"] span{color:var(--bg);opacity:.8}
.day-bars{display:flex;gap:2px;height:4px;margin-top:2px}
.day-bars span{width:8px;height:4px;border-radius:2px}
.tile-next{display:flex;flex-direction:column;min-width:0}
.tile-next .s1{font-size:14px;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tile-next .s2{font-size:13px;color:var(--muted)}
.tile-late{font-size:13px;font-weight:600;color:var(--amber)}
.late-block .list{background:var(--amber-soft);border-color:var(--amber-line)}
.ok-line{color:var(--green);font-weight:600}
