/* habits: summary, habit cards, contribution grid, day editor, habit detail & editor */
/* ---------- HABITS ---------- */
.habits{height:100%;overflow-y:auto;padding-block:18px 100px}   /* room for Core's round + */
.hsum{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:24px;align-items:center;padding:18px 20px;background:var(--surface);border:1px solid var(--line);border-radius:14px}
.today-big{display:flex;align-items:center;gap:16px}
.ring{--p:0;width:64px;height:64px;border-radius:50%;background:conic-gradient(var(--accent) calc(var(--p)*1turn),var(--cell) 0);display:grid;place-items:center;flex:none}
.ring::before{content:"";grid-area:1/1;width:50px;height:50px;border-radius:50%;background:var(--surface)}
.ring span{grid-area:1/1;position:relative;font-family:var(--mono);font-size:13px;font-weight:500}
.today-big .lbl{font-size:11.5px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600}
.today-big .val{font-family:var(--display);font-size:28px;font-weight:700;line-height:1.1}
.week{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:6px;max-width:460px;justify-self:center;width:100%}
.wd{display:flex;flex-direction:column;align-items:center;gap:5px;font-size:11.5px;color:var(--muted)}
.wd .b{width:100%;max-width:44px;height:40px;border-radius:8px;background:var(--cell);position:relative;overflow:hidden}
.wd .b i{position:absolute;left:0;right:0;bottom:0;background:var(--accent);opacity:.85}
.wd.is-today{color:var(--fg);font-weight:700}
.wd.is-today .b{outline:1.5px solid var(--accent);outline-offset:2px}
.wd.future .b{background:var(--cell-off)}
.month{text-align:right}
.month .val{font-family:var(--display);font-size:28px;font-weight:700;line-height:1.1}
.month .lbl{font-size:11.5px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600}
.htools{display:flex;align-items:center;gap:10px;margin:22px 0 12px;flex-wrap:wrap}
.htools h2{margin:0;font-family:var(--display);font-size:18px;font-weight:600;flex:1}
.hgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,380px),1fr));gap:14px}
.hcard{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:14px 16px 16px;display:flex;flex-direction:column;gap:12px;--hc:var(--accent)}
.hcard.archived{opacity:.6}
.hc-top{display:flex;align-items:center;gap:12px}
.hicon{width:42px;height:42px;border-radius:11px;display:grid;place-items:center;font-size:21px;background:color-mix(in srgb,var(--hc) 20%,var(--surface));flex:none}
.hname{flex:1;min-width:0;text-align:left}
.hname b{display:block;font-weight:600;font-size:15px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hname small{color:var(--muted);font-size:12px}
.tap{--p:0;position:relative;width:52px;height:52px;border-radius:50%;flex:none;background:conic-gradient(var(--hc) calc(var(--p)*1turn),var(--cell) 0);display:grid;place-items:center;touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.tap::before{content:"";grid-area:1/1;width:42px;height:42px;border-radius:50%;background:var(--surface);transition:background .15s}
.tap.full::before{background:var(--hc)}
.tap span{grid-area:1/1;position:relative;font-family:var(--mono);font-size:12px;font-weight:500}
.tap.full span{color:var(--bg)}
.tap svg{grid-area:1/1;position:relative;width:20px;height:20px}
.tap.full svg{color:var(--bg)}
.tap:active::before{transform:scale(.94)}
.streaks{display:flex;gap:18px;font-size:12.5px;color:var(--muted)}
.streaks b{font-family:var(--mono);color:var(--fg);font-weight:500;font-size:13px}
.contrib{display:grid;grid-template-rows:repeat(7,1fr);grid-auto-flow:column;grid-auto-columns:1fr;gap:3px}
.sq{aspect-ratio:1;border-radius:3px;background:var(--cell);max-width:100%}
button.sq{cursor:pointer}
button.sq:hover{outline:1.5px solid var(--fg);outline-offset:0}
.sq.off{background:var(--cell-off);background-image:radial-gradient(circle,var(--line-strong) 1px,transparent 1.5px)}
.sq.part{background:color-mix(in srgb,var(--hc) 38%,var(--cell))}
.sq.full{background:var(--hc)}
.sq.fut{background:transparent}
.sq.today{outline:1.5px solid var(--fg);outline-offset:1px}
.months{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;gap:3px;font-size:10.5px;color:var(--faint);height:14px}
.months span{white-space:nowrap;overflow:visible}
.empty-h{background:var(--surface);border:1px dashed var(--line-strong);border-radius:14px;padding:28px;text-align:center;display:flex;flex-direction:column;gap:14px;align-items:center}
.empty-h h3{margin:0;font-family:var(--display);font-size:18px}
.empty-h p{margin:0;color:var(--muted);max-width:48ch}
.tpl{display:flex;gap:8px;flex-wrap:wrap;justify-content:center}
.pop-h{font-weight:600;font-size:13px}
.pop-h small{display:block;color:var(--muted);font-weight:400}
.stepper{display:grid;grid-template-columns:40px 1fr 40px;gap:6px}
.stepper button{height:38px;border-radius:8px;background:var(--raised);border:1px solid var(--line);font-size:18px}
.stepper input{text-align:center;font-family:var(--mono)}
.rates{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.rate{background:var(--sunk);border:1px solid var(--line);border-radius:10px;padding:10px 12px}
.rate b{display:block;font-family:var(--display);font-size:22px}
.rate span{font-size:12px;color:var(--muted)}
.cal{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}
.cal .dn{font-size:11px;color:var(--faint);text-align:center;padding-bottom:2px}
.cal .cd{aspect-ratio:1;border-radius:8px;display:grid;place-items:center;font-size:12.5px;font-family:var(--mono);background:var(--cell);border:0;max-width:100%}
.cal .cd.off{background:var(--cell-off);color:var(--faint)}
.cal .cd.part{background:color-mix(in srgb,var(--hc) 38%,var(--cell))}
.cal .cd.full{background:var(--hc);color:var(--bg)}
.cal .cd.fut{background:transparent;color:var(--faint);cursor:default}
.cal .cd.today{outline:1.5px solid var(--fg)}
.cal .pad{visibility:hidden}
.runs{display:flex;flex-direction:column;gap:6px}
.run{display:grid;grid-template-columns:70px 1fr;gap:10px;align-items:center;font-size:12.5px}
.run .rb{height:8px;border-radius:4px;background:var(--hc)}
.run .rt{color:var(--muted)}
.chart text{fill:var(--muted);font-size:10px;font-family:var(--mono)}
.chart line{stroke:var(--line)}
.sec-h{font-size:11.5px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600;margin:0 0 8px}
.emojis{display:grid;grid-template-columns:repeat(auto-fill,minmax(36px,1fr));gap:4px;max-height:132px;overflow-y:auto;padding:4px;background:var(--sunk);border:1px solid var(--line);border-radius:8px}
.emojis button{height:36px;border-radius:7px;font-size:19px}
.emojis button:hover,.emojis button[aria-pressed="true"]{background:var(--raised)}
.colors{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.colors button{width:28px;height:28px;border-radius:8px;background:var(--c);border:2px solid transparent}
.colors button[aria-pressed="true"]{border-color:var(--fg)}
.colors input[type="color"]{width:34px;height:30px;padding:2px;border:1px solid var(--line);border-radius:8px;background:var(--sunk)}
.days{display:flex;gap:6px;flex-wrap:wrap}
.days button{width:40px;height:34px;border-radius:8px;border:1px solid var(--line);background:var(--sunk);font-size:12.5px;font-weight:600;color:var(--muted)}
.days button[aria-pressed="true"]{background:var(--accent);color:var(--accent-ink);border-color:transparent}
.sheet .stepper button{height:46px}
.sheet .stepper input{height:46px;font-size:18px}
.contrib-wrap{overflow-x:auto;scrollbar-width:thin}
.sq,.cal .cd,.tap{touch-action:manipulation;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
@media (max-width:860px){
  .hsum{grid-template-columns:1fr auto;gap:16px}
  .week{grid-column:1/-1;grid-row:2;max-width:none}
  .contrib,.months{grid-auto-columns:32px;width:max-content}
  .contrib{gap:4px}
  .months{gap:4px}
  .sq{width:32px;height:32px;border-radius:5px}
  /* compact phone shell: Core's header shows the title, the round + adds a habit */
  .habits{padding-bottom:calc(150px + env(safe-area-inset-bottom,0px))}
  .htools{margin:14px 0 10px}
  .htools h2,.htools:not(.is-empty) .hnew-top{display:none}
  .htools.no-arch:not(.is-empty){justify-content:flex-end}
  .hgrid{margin-top:14px}
}

/* v2: view switch, milestone line, project chip, week and month views */
.htools .hview{margin-left:auto}
.htools .hview + .btn, .htools .hview ~ .hnew-top{margin-left:0}
.hjour{display:grid;grid-template-columns:1fr auto;gap:4px 10px;font-size:12px;color:var(--muted);margin:2px 0 8px}
.hjour b{color:var(--fg)}
.hjbar{grid-column:1/-1;height:4px;border-radius:3px;background:var(--sunk);overflow:hidden}
.hjbar i{display:block;height:100%;background:var(--hc,var(--accent));border-radius:3px}
.hproj{display:inline-flex;align-items:center;gap:5px;color:var(--muted);max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hproj i{width:8px;height:8px;border-radius:50%;background:var(--c);flex:none}
.hcal{gap:4px}
.hcal .cd{min-height:30px}
.wview{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:10px 12px;display:flex;flex-direction:column;gap:6px}
.wv-nav{display:flex;align-items:center;justify-content:space-between;gap:8px}
.wv-row{display:grid;grid-template-columns:minmax(0,1.6fr) repeat(7,minmax(34px,1fr));gap:6px;align-items:center}
.wv-h span{text-align:center;font-size:11px;color:var(--muted);display:flex;flex-direction:column;line-height:1.2}
.wv-h span small{font-family:var(--mono);font-size:10.5px}
.wv-h span.is-today{color:var(--accent);font-weight:600}
.wv-name{display:flex;align-items:center;gap:6px;min-width:0;text-align:left;padding:6px 2px}
.wv-name b{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.wv-c{height:34px;border-radius:9px;background:var(--sunk);display:grid;place-items:center;color:#fff;font-size:12px;font-family:var(--mono)}
.wv-c.part{background:color-mix(in srgb,var(--hc) 40%,var(--sunk))}
.wv-c.full{background:var(--hc)}
.wv-c.off{opacity:.45}
.wv-c.today{outline:2px solid var(--fg);outline-offset:-2px}
.wv-c.fut{background:none;border:1px dashed var(--line)}
.wv-c svg{width:16px;height:16px}
@media (max-width:860px){
  .wv-row{grid-template-columns:repeat(7,minmax(0,1fr));gap:4px 5px}
  .wv-h > span:first-child{display:none}
  .wv-name{grid-column:1/-1;padding:6px 2px 0}
}
.hcard:not(.archived) .hicon, .hcard:not(.archived) .hname, .wv-row[data-id] .wv-name{cursor:grab}
.hcard:not(.archived) .hicon, .wv-row[data-id] .wv-name > span{touch-action:none}
@media (max-width:860px){ .wv-name span{display:inline} }
