/* The same quiet utility button and progress overlay in all three apps. */
.habit-stats-launcher { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: auto; min-height: 40px; padding: 8px 12px; border: 1px solid #c9c3ba; border-radius: 9px; background: #fffdf8; color: #29251f; font: 600 12px/1.2 system-ui, sans-serif; cursor: pointer; pointer-events: auto; text-decoration: none; }
.habit-stats-launcher svg { width: 16px; height: 16px; flex: 0 0 auto; }
.habit-stats-launcher:hover { background: #f1ece3; }
/* Session apps expose Stats exclusively inside their startup/settings overlays. */
html[data-habit-stats-scope="overlays"] [data-open-stats] { display: none !important; }
html[data-habit-stats-scope="overlays"] :is(#onboarding, #sessionStart):not(.hidden):not([hidden]) [data-open-stats]:not([hidden]) { display: inline-flex !important; }
.top-links:has(.habit-stats-launcher) { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
dialog.habit-stats { box-sizing: border-box; width: min(740px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: auto; border: 1px solid #c9c3ba; border-radius: 18px; background: #faf8f4; color: #29251f; box-shadow: 0 24px 80px #0003; font: 14px/1.5 system-ui, sans-serif; text-align: left; user-select: text; }
dialog.habit-stats::backdrop { background: #19171180; backdrop-filter: blur(4px); }
.habit-stats *, .habit-stats *::before, .habit-stats *::after { box-sizing: border-box; }
.habit-stats [hidden] { display: none !important; }
.habit-stats .hs-header { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px 26px 18px; border-bottom: 1px solid #e2ddd4; background: #fffdf8; }
.habit-stats h1, .habit-stats h2, .habit-stats p { margin: 0; color: inherit; }
.habit-stats h1 { font-size: 25px; line-height: 1.25; letter-spacing: -.025em; }
.habit-stats h2 { font-size: 16px; line-height: 1.4; font-weight: 650; }
.habit-stats .hs-eyebrow { margin-bottom: 6px; color: #6c655a; font-size: 10px; letter-spacing: .12em; }
.habit-stats button { width: auto; min-height: 40px; padding: 8px 12px; margin: 0; border: 1px solid #bfb7ab; border-radius: 8px; background: #fffdf8; color: #29251f; font: 600 12px/1.4 system-ui, sans-serif; cursor: pointer; transform: none; box-shadow: none; }
.habit-stats button:hover { background: #eee7db; transform: none; }
.habit-stats .hs-close { display: grid; place-items: center; width: 42px; min-height: 42px; flex: 0 0 auto; padding: 0; font-size: 26px; font-weight: 400; }
.habit-stats :is(button, input):focus-visible, .habit-stats-launcher:focus-visible { outline: 3px solid #53745a; outline-offset: 3px; }
.habit-stats .hs-body { padding: 22px 26px; }
.habit-stats .hs-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.habit-stats .hs-metrics > div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; padding: 16px 12px; border: 1px solid #e2ddd4; border-radius: 12px; background: #fffdf8; }
.habit-stats .hs-metrics strong { font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.habit-stats .hs-metrics span { color: #6c655a; font-size: 11px; }
.habit-stats .hs-section { padding: 22px 0; border-bottom: 1px solid #e2ddd4; }
.habit-stats .hs-section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.habit-stats .hs-section-heading > span { color: #6c655a; font-size: 12px; font-variant-numeric: tabular-nums; }
.habit-stats progress { display: block; width: 100%; height: 10px; margin: 14px 0; border: 0; border-radius: 20px; overflow: hidden; background: #e9e4da; accent-color: #42634b; }
.habit-stats progress::-webkit-progress-bar { background: #e9e4da; }
.habit-stats progress::-webkit-progress-value { background: #42634b; border-radius: 20px; }
.habit-stats progress::-moz-progress-bar { background: #42634b; border-radius: 20px; }
.habit-stats .hs-goal-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; }
.habit-stats .hs-goal-form input { width: 68px; min-height: 40px; padding: 6px 8px; border: 1px solid #bfb7ab; border-radius: 7px; background: #fff; color: #29251f; font: 16px system-ui, sans-serif; }
.habit-stats .hs-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 18px 0 14px; list-style: none; }
.habit-stats .hs-week li { display: flex; flex-direction: column; align-items: center; gap: 7px; color: #746c60; font-size: 11px; }
.habit-stats .hs-bar-value { font-size: 10px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.habit-stats .hs-bar-track { display: flex; align-items: flex-end; width: min(100%, 40px); height: 85px; border-radius: 6px; overflow: hidden; background: #ece7dd; }
.habit-stats .hs-bar { display: block; width: 100%; min-height: 0; border-radius: 6px; background: #849a7f; }
.habit-stats .is-today .hs-bar { background: #42634b; }
.habit-stats .is-today { color: #29251f; font-weight: 650; }
.habit-stats .hs-help { margin: 10px 0 0; color: #746c60; font-size: 12px; line-height: 1.6; }
.habit-stats .hs-history { margin: 12px 0 0; padding: 0; list-style: none; }
.habit-stats .hs-history li { display: flex; justify-content: space-between; gap: 18px; padding: 12px 0; border-top: 1px solid #ebe6dd; }
.habit-stats .hs-history li:first-child { border-top: 0; }
.habit-stats .hs-history li > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.habit-stats .hs-history li > div:last-child { flex: 0 0 auto; text-align: right; }
.habit-stats .hs-history strong { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.habit-stats .hs-history span { font-size: 11px; color: #746c60; }
.habit-stats .hs-empty { padding: 20px 0 0; color: #746c60; font-size: 12px; }
.habit-stats .hs-backup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.habit-stats [data-export] { background: #314c38; color: #fff; border-color: #314c38; }
.habit-stats [data-export]:hover { background: #233b2a; }
.habit-stats .hs-status { min-height: 20px; padding-top: 12px; color: #425d46; font-size: 12px; }
.habit-stats .hs-footer { margin-top: 8px; color: #80776a; font-size: 11px; line-height: 1.6; }
@media (max-width: 520px) {
  dialog.habit-stats { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); border-radius: 14px; }
  .habit-stats .hs-header { padding: 18px 16px 14px; }
  .habit-stats h1 { font-size: 22px; }
  .habit-stats .hs-body { padding: 18px 16px; }
  .habit-stats .hs-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .habit-stats .hs-metrics > div { padding: 12px; }
  .habit-stats .hs-week { gap: 5px; }
  .habit-stats .hs-bar-value { font-size: 9px; }
  .habit-stats .hs-history li { gap: 12px; }
  .habit-stats .hs-backup-actions button { flex: 1 1 auto; }
}
