/* ===== Habit Tracker ===== */
.page-hb { padding: 12px 14px 90px; max-width: 640px; margin: 0 auto; }
.hb-top { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.hb-top h2 { font-family:'Cormorant Garamond',serif; font-size:22px; margin:0; text-align:center; flex:1; }
.hb-daynav { display:flex; align-items:center; gap:10px; }
.hb-daylabel { font-weight:600; min-width:88px; text-align:center; }
.hb-stats-btn { background:none; border:none; font-size:20px; cursor:pointer; padding:4px; }
.cal-nav-btn[disabled] { opacity:.3; }

/* Day score ring */
.hb-dayscore { display:flex; align-items:center; gap:16px; background:#fff; border:1px solid #eae4dc; border-radius:16px; padding:14px 16px; margin-bottom:12px; }
.hb-ring { --pct:0; width:70px; height:70px; border-radius:50%; flex-shrink:0;
  background: conic-gradient(#8fae7d calc(var(--pct)*1%), #efe7dc 0);
  display:grid; place-items:center; position:relative; }
.hb-ring::after { content:''; position:absolute; inset:8px; background:#fff; border-radius:50%; }
.hb-ring-num { position:relative; z-index:1; font-weight:700; font-size:19px; color:#2c2a28; }
.hb-ring-num small { font-size:11px; }
.hb-dayscore-count { font-weight:600; margin-bottom:2px; }
.hb-dayscore-msg { font-size:13px; color:#8a8580; }

.hb-narrative { text-align:center; margin-bottom:14px; cursor:pointer; }
.hb-narr-text { font-family:'Cormorant Garamond',serif; font-style:italic; font-size:17px; color:#8a6f52; }
.hb-narr-empty { color:#b7ad9f; font-size:13px; }

/* Tag filter chips */
.hb-filter { display:flex; gap:6px; overflow-x:auto; padding-bottom:4px; margin-bottom:14px; -webkit-overflow-scrolling:touch; }
.hb-chip { flex-shrink:0; padding:6px 14px; border:1px solid #e2dacf; background:#fff; border-radius:20px; font-size:13px; cursor:pointer; color:#6a625a; white-space:nowrap; }
.hb-chip.sel { background:#b98a5e; color:#fff; border-color:#b98a5e; }

/* Category Day Score */
.hb-cat-row { display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.hb-cat-name { font-size:13px; min-width:80px; max-width:110px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#6a625a; }
.hb-cat-bar { flex:1; height:8px; background:#efe7dc; border-radius:5px; overflow:hidden; }
.hb-cat-fill { height:100%; background:#8fae7d; border-radius:5px; transition:width .3s; }
.hb-cat-val { font-size:12px; color:#8a8580; min-width:34px; text-align:right; }

/* Section */
.hb-section { margin-bottom:18px; }
.hb-section-head { display:flex; justify-content:space-between; align-items:baseline; margin-bottom:6px; }
.hb-section-title { font-weight:600; font-size:15px; }
.hb-section-prog { font-size:13px; color:#8a8580; }
.hb-section-bar { height:5px; background:#efe7dc; border-radius:3px; overflow:hidden; margin-bottom:10px; }
.hb-section-fill { height:100%; background:#8fae7d; border-radius:3px; transition:width .3s; }

/* Card */
.hb-cards { display:flex; flex-direction:column; gap:8px; }
.hb-card { display:flex; align-items:center; gap:10px; background:#fff; border:1px solid #eae4dc; border-radius:14px; padding:10px 12px; transition:.2s, border-color 0.4s ease; }
.hb-health-green { border-color: #4caf50; }
.hb-health-yellow { border-color: #ffc107; }
.hb-health-red { border-color: #f44336; }
.hb-card.is-done { background:#f6faf3; }
.hb-card.offday { opacity:.5; }
.hb-card-main { display:flex; align-items:center; gap:10px; flex:1; min-width:0; cursor:pointer; }
.hb-icon { width:38px; height:38px; border-radius:11px; display:grid; place-items:center; font-size:19px; flex-shrink:0; }
.hb-card-txt { min-width:0; }
.hb-card-name { font-weight:600; font-size:15px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.hb-neg { background:#f3d9d5; color:#b0574e; font-size:10px; padding:1px 5px; border-radius:6px; }
.hb-streak { font-size:12px; color:#c98a4a; }
.hb-note-badge, .hb-sub-badge { font-size:12px; }
.hb-sub-badge { background:#efe7dc; border-radius:8px; padding:1px 7px; cursor:pointer; }
.hb-tags { display:flex; gap:4px; flex-wrap:wrap; margin-top:3px; }
.hb-tag { font-size:11px; background:#f0ece4; color:#8a7f6f; padding:1px 8px; border-radius:10px; }
.hb-offday { font-size:12px; color:#b7ad9f; }
.hb-more { background:none; border:none; color:#b7ad9f; font-size:22px; line-height:1; padding:0 6px; cursor:pointer; flex-shrink:0; }

/* Check button */
.hb-check { width:40px; height:40px; border-radius:50%; border:2px solid #d8cfc2; background:#fff; font-size:19px; color:#fff; flex-shrink:0; cursor:pointer; transition:.15s; display:grid; place-items:center; }
.hb-check.done { color:#fff; }
.hb-check.skip { background:#e8dcc8; border-color:#e8dcc8; color:#a08b60; }
.hb-check.fail { background:#f0d5d0; border-color:#d99; color:#b0574e; }
.hb-check.pop { transform:scale(1.25); }

/* Numeric */
.hb-num { display:flex; align-items:center; gap:8px; flex-shrink:0; width:150px; }
.hb-num-btn { width:32px; height:32px; border-radius:50%; border:1px solid #d8cfc2; background:#fff; font-size:18px; cursor:pointer; flex-shrink:0; }
.hb-num-mid { flex:1; text-align:center; }
.hb-num-val { font-weight:600; font-size:14px; }
.hb-num-target { color:#b7ad9f; font-weight:400; font-size:12px; }
.hb-num-bar { height:4px; background:#efe7dc; border-radius:2px; margin-top:3px; overflow:hidden; }
.hb-num-fill { height:100%; border-radius:2px; transition:width .25s; }

.hb-empty { text-align:center; color:#a89e8e; padding:50px 20px; line-height:1.6; }
.hb-add-fab { position:fixed; left:50%; transform:translateX(-50%); bottom:74px; background:#b98a5e; color:#fff; border:none; border-radius:24px; padding:13px 26px; font-size:15px; font-weight:600; box-shadow:0 6px 18px rgba(140,100,60,.35); cursor:pointer; z-index:50; }

/* Edit form */
.hb-edit form { display:flex; flex-direction:column; }
.hb-l { font-size:12px; color:#8a8580; margin:14px 0 5px; font-weight:600; }
.hb-input { width:100%; padding:11px 13px; border:1px solid #e2dacf; border-radius:10px; font-size:15px; background:#fff; font-family:inherit; }
textarea.hb-input { resize:vertical; }
.hb-row2 { display:flex; gap:10px; }
.hb-row2 > div { flex:1; }
.hb-pick { display:flex; flex-wrap:wrap; gap:6px; }
#hb-icons { max-height:168px; overflow-y:auto; padding:2px; }
.hb-pick-i { width:40px; height:40px; border-radius:11px; border:1px solid #e2dacf; background:#fff; font-size:19px; cursor:pointer; }
.hb-pick-i.sel { border-color:#b98a5e; background:#f6efe4; }
.hb-pick-c { width:30px; height:30px; border-radius:50%; border:3px solid transparent; cursor:pointer; }
.hb-pick-c.sel { border-color:#2c2a28; }
.hb-seg { display:flex; gap:6px; flex-wrap:wrap; }
.hb-seg button { flex:1; min-width:90px; padding:9px; border:1px solid #e2dacf; background:#fff; border-radius:10px; cursor:pointer; font-size:13px; }
.hb-seg button.sel { background:#b98a5e; color:#fff; border-color:#b98a5e; }
.hb-days { display:flex; gap:5px; }
.hb-day { flex:1; padding:9px 0; border:1px solid #e2dacf; background:#fff; border-radius:9px; cursor:pointer; font-size:13px; }
.hb-day.sel { background:#8fae7d; color:#fff; border-color:#8fae7d; }
.hb-toggle { display:flex; align-items:center; gap:8px; margin:16px 0; font-size:14px; }
.hb-save-btn { margin-top:20px; padding:14px; background:#b98a5e; color:#fff; border:none; border-radius:12px; font-size:16px; font-weight:600; cursor:pointer; }
.hb-del-btn { margin-top:12px; padding:12px; background:none; color:#c0574e; border:1px solid #e3c4bf; border-radius:12px; font-size:14px; cursor:pointer; }

/* Detail metrics */
.hb-intention { background:#fbf3e6; border-radius:10px; padding:10px 12px; font-size:14px; color:#8a6f52; margin-bottom:12px; }
.hb-metrics { display:flex; gap:8px; margin-bottom:14px; }
.hb-metric { flex:1; background:#fff; border:1px solid #eae4dc; border-radius:12px; padding:12px 4px; text-align:center; }
.hb-metric-num { font-size:24px; font-weight:700; }
.hb-metric-l { font-size:11px; color:#8a8580; margin-top:2px; }
.hb-pace { padding:10px 12px; border-radius:10px; font-size:14px; margin-bottom:10px; }
.hb-pace.ok { background:#eef5e9; color:#5a7d4f; }
.hb-pace.behind { background:#fbeee6; color:#b57a45; }
.hb-reward { background:#faf1f4; border-radius:10px; padding:10px 12px; font-size:14px; color:#a06a80; margin-bottom:10px; }
.hb-block-title { font-weight:600; font-size:14px; margin:18px 0 8px; color:#6a625a; }

/* Heatmap */
.hb-heatmap-wrap { overflow-x:auto; padding-bottom:4px; }
.hb-heatmap { display:flex; gap:3px; }
.hb-heat-col { display:flex; flex-direction:column; gap:3px; }
.hb-heat { width:13px; height:13px; border-radius:3px; background:#efe7dc; }
.hb-heat.off { background:#f4f0e9; }
.hb-heat.miss { background:#ecd9d4; }
.hb-heat.skip { background:#e6dcc6; }
.hb-heat.done { background:#8fae7d; }
.hb-heat.future { background:transparent; }

/* Trend chart */
.hb-trend-wrap { background:#fff; border:1px solid #eae4dc; border-radius:12px; padding:8px 10px; overflow:hidden; }
@media (prefers-color-scheme: dark) {
  .hb-trend-wrap { background:#211f1d; border-color:#38332e; }
}

/* Numeric value bar chart (detail view) */
.hb-numchart { display:flex; gap:4px; align-items:end; height:90px; margin-bottom:14px; }
.hb-numchart-col { flex:1; display:flex; flex-direction:column; align-items:center; gap:2px; height:100%; }
.hb-numchart-val { font-size:9px; color:#8a8580; min-height:12px; line-height:12px; }
.hb-numchart-track { flex:1; width:100%; background:#efe7dc; border-radius:4px; display:flex; align-items:end; overflow:hidden; }
.hb-numchart-fill { width:100%; border-radius:4px; transition:height .3s; }
.hb-numchart-day { font-size:9px; color:#8a8580; }
.hb-numchart-today { font-weight:700; color:#b98a5e; }
.hb-numchart-avg { font-weight:400; font-size:12px; color:#8a8580; margin-left:8px; }

/* Weekbars */
.hb-weekbars { display:flex; gap:6px; align-items:end; height:90px; }
.hb-weekbar { flex:1; display:flex; flex-direction:column; align-items:center; gap:4px; height:100%; }
.hb-weekbar-track { flex:1; width:100%; background:#efe7dc; border-radius:5px; display:flex; align-items:end; overflow:hidden; }
.hb-weekbar-fill { width:100%; border-radius:5px; transition:height .3s; }
.hb-weekbar span { font-size:11px; color:#8a8580; }

/* Stats */
.hb-daytrend { display:flex; gap:3px; align-items:end; height:70px; background:#fff; border:1px solid #eae4dc; border-radius:12px; padding:10px; }
.hb-daytrend-bar { flex:1; height:100%; display:flex; align-items:end; }
.hb-daytrend-bar > div { width:100%; background:#8fae7d; border-radius:3px; min-height:2px; }
.hb-stat-row { display:flex; align-items:center; gap:10px; background:#fff; border:1px solid #eae4dc; border-radius:12px; padding:10px 12px; margin-bottom:8px; cursor:pointer; }
.hb-stat-name { flex:1; font-weight:600; }
.hb-stat-vals { font-size:12px; color:#8a8580; }

/* Action sheet */
.hb-sheet-overlay { position:fixed; inset:0; background:rgba(0,0,0,.3); z-index:200; display:flex; align-items:flex-end; }
.hb-sheet { background:#fff; width:100%; border-radius:18px 18px 0 0; padding:14px; display:flex; flex-direction:column; gap:8px; max-width:640px; margin:0 auto; }
.hb-sheet-title { font-weight:600; text-align:center; padding:6px; }
.hb-sheet button { padding:14px; border:none; background:#f4f0e9; border-radius:12px; font-size:15px; text-align:left; cursor:pointer; }
.hb-sheet-cancel { text-align:center !important; color:#8a8580; }
.hb-sub-row { display:flex; align-items:center; gap:10px; padding:10px 4px; }

/* Freeze badge */
.hb-freeze-badge { font-size:12px; color:#6a8fbf; }

/* Season banner */
.hb-season-banner { text-align:center; background:linear-gradient(135deg,#f6efe4,#eef5e9); border:1px solid #d8c8a8; border-radius:14px; padding:14px 16px; margin-bottom:14px; font-family:'Cormorant Garamond',serif; font-size:17px; color:#8a6f52; cursor:pointer; animation:hbfade .4s; }

/* Celebrate */
.hb-celebrate { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:300; display:grid; place-items:center; animation:hbfade .3s; }
.hb-celebrate-card { background:#fff; border:3px solid; border-radius:20px; padding:28px 32px; text-align:center; max-width:300px; }
.hb-celebrate-emoji { font-size:48px; }
.hb-celebrate-title { font-family:'Cormorant Garamond',serif; font-size:24px; font-weight:700; margin:8px 0; }
.hb-celebrate-sub { color:#8a8580; font-size:14px; margin-bottom:16px; }
.hb-celebrate-card button { background:#b98a5e; color:#fff; border:none; border-radius:12px; padding:11px 28px; font-size:15px; font-weight:600; cursor:pointer; }
@keyframes hbfade { from{opacity:0} to{opacity:1} }

/* Partner */
.hb-partner-link { width:100%; margin-bottom:10px; padding:12px; border:1px dashed #d8ccb8; background:#fbf6ee; color:#8a6f52; border-radius:12px; font-size:14px; cursor:pointer; }
.hb-partner-card { background:#fff; border:1px solid #eae4dc; border-radius:16px; padding:14px; margin-bottom:12px; }
.hb-partner-head { display:flex; align-items:center; gap:14px; }
.hb-partner-name { font-weight:700; font-size:16px; text-transform:capitalize; }
.hb-partner-sub { font-size:13px; color:#8a8580; }
.hb-partner-x { margin-left:auto; background:none; border:none; color:#c3b8a6; font-size:16px; cursor:pointer; }
.hb-partner-habits { margin-top:12px; display:flex; flex-direction:column; gap:8px; }
.hb-partner-habit { display:flex; align-items:center; gap:10px; }
.hb-partner-hname { flex:1; font-size:14px; }
.hb-partner-streak { font-size:13px; font-weight:600; }
.hb-partner-actions { display:flex; flex-direction:column; gap:8px; margin-bottom:8px; }
.hb-invite-code { font-family:'Cormorant Garamond',serif; font-size:34px; font-weight:700; letter-spacing:4px; text-align:center; background:#f6efe4; border-radius:12px; padding:14px; margin-top:8px; color:#8a6f52; }
.hb-invite-hint { font-size:13px; color:#8a8580; text-align:center; margin:8px 0; }

@media (prefers-color-scheme: dark) {
  .hb-partner-card { background:#211f1d; border-color:#38332e; }
  .hb-partner-link { background:#26221c; border-color:#453d31; }
  .hb-invite-code { background:#2a2419; }
  .hb-chip { background:#211f1d; border-color:#38332e; color:#c9c1b5; }
  .hb-dayscore,.hb-card,.hb-metric,.hb-stat-row,.hb-daytrend,.hb-sheet { background:#211f1d; border-color:#38332e; }
  .hb-card.is-done { background:#1e241a; }
  .hb-input,.hb-pick-i,.hb-seg button,.hb-day,.hb-num-btn { background:#211f1d; border-color:#38332e; color:#e8e2d8; }
  .hb-ring::after { background:#211f1d; }
  .hb-ring-num { color:#e8e2d8; }
}
