body { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
main { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.badge { margin-left: auto; font-size: 0.8rem; background: var(--lime); color: var(--ink); padding: 0.2rem 0.6rem; border-radius: 999px; font-weight: 560; }
/* Mobile first: the views sit in a bottom bar within thumb reach; from 760px they move to the top. */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0.25rem 0.25rem calc(0.25rem + env(safe-area-inset-bottom));
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; border: 0; border-radius: 14px; background: none; font-size: 0.72rem; font-weight: 600; color: var(--muted);
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current='page'] { color: var(--ink); }
.tabs button[aria-current='page'] svg { background: var(--lime); border-radius: 999px; width: 52px; padding: 2px 14px; box-sizing: content-box; margin: 0 -14px; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) {
  .tabs { position: sticky; top: 0; bottom: auto; display: flex; gap: 0.25rem; padding: 0.5rem 1rem; border-top: 0; border-bottom: 1px solid var(--line); background: var(--canvas); }
  .tabs button { flex-direction: row; min-height: 40px; padding: 0 0.9rem; border-radius: 999px; font-size: 0.95rem; gap: 0.4rem; }
  .tabs svg { width: 18px; height: 18px; }
  .tabs button[aria-current='page'] { background: var(--ink); color: #fff; }
  .tabs button[aria-current='page'] svg { background: none; width: 18px; padding: 0; margin: 0; }
  body { padding-bottom: 0; }
}
.view-head { margin: 0.5rem 0 1rem; }
.view-head.row { flex-wrap: wrap; }
#month-title, #year-title { font-size: clamp(1.35rem, 5vw, 2.2rem); min-width: 9ch; text-align: center; }
@media (max-width: 520px) {
  #month-print { order: 5; width: 100%; }
  .view-head .grow { display: none; }
  .month .name-col { min-width: 6.5rem; max-width: 7.5rem; }
}
.view-head h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.row { display: flex; align-items: center; gap: 0.5rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 0.6rem; }
.pad { padding: 1rem; }
.small { font-size: 0.875rem; }
.card + .card { margin-top: 0.75rem; }
.btn.icon { width: 44px; padding: 0; font-size: 1.3rem; }
.btn:disabled { opacity: 0.35; cursor: default; }

/* Today */
.today-list { display: grid; gap: 0.75rem; }
.habit { display: flex; gap: 0.9rem; align-items: flex-start; padding: 0.9rem; border-left: 6px solid var(--c); }
.tick {
  flex: none; width: 56px; height: 56px; border-radius: 16px; border: 2px solid var(--line-strong);
  background: var(--surface); color: transparent; display: grid; place-items: center;
  transition: transform 0.12s var(--ease, ease), background 0.15s;
}
.tick svg { width: 30px; height: 30px; }
.tick:active { transform: scale(0.94); }
.is-done .tick { background: var(--c); border-color: var(--c); color: var(--ink); }
.habit-body { min-width: 0; flex: 1; }
.habit-name { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.is-done .habit-name { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--c); }
.week { display: flex; gap: 0.3rem; margin-top: 0.5rem; }
.dot {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 0.7rem; color: var(--muted); padding: 0;
}
.dot.on { background: var(--c); border-color: var(--c); color: var(--ink); font-weight: 640; }
.empty { padding: 1.25rem; }
.empty h2 { font-size: 1.3rem; margin-bottom: 0.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.9rem 0; }
.chip { min-height: 38px; padding: 0 0.8rem; border-radius: 999px; border: 1px dashed var(--line-strong); background: var(--lime-50); }
.chip:hover { border-color: var(--ink); }
.add-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.add-form input, .habit-edit input, select {
  min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 0.75rem; background: var(--surface);
}
.add-form input { flex: 1 1 12rem; min-width: 0; }

/* Month: one calendar per habit, mobile first */
.month-list { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.month-card { border-left: 6px solid var(--c); }
.month-card + .month-card { margin-top: 0; }
.month-card h2 { font-size: 1.05rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 0.75rem; }
.cal-wd { text-align: center; font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.cal-day {
  aspect-ratio: 1; min-height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--subtle);
  font-size: 0.85rem; font-weight: 560; padding: 0;
}
.cal-day.on { background: var(--c); border-color: var(--c); }
.cal-day.is-today { outline: 2px solid var(--ink); outline-offset: 1px; }
.cal-day:disabled { background: none; border-style: dashed; color: var(--line-strong); cursor: default; }
.toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
@media (min-width: 760px) { .toast { bottom: 1.5rem; } }
/* (old table styles below are unused by the app, kept for the print sheet's shape) */
.month-wrap { overflow-x: auto; }
.month { border-collapse: separate; border-spacing: 2px; font-size: 0.8rem; }
.month th { font-weight: 560; color: var(--muted); padding: 0.2rem; text-align: center; line-height: 1.1; }
.month th .wd { display: block; font-size: 0.65rem; }
.month th.is-today { color: var(--ink); background: var(--lime-50); border-radius: 6px; }
.month .name-col {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; color: var(--ink);
  min-width: 8rem; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 0.5rem;
  border-left: 5px solid var(--c, transparent);
}
.cell { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--subtle); padding: 0; display: block; }
.cell.on { background: var(--c); border-color: var(--c); }
.cell.future { background: none; border-style: dashed; }
.pct { font-weight: 600; text-align: right; padding-left: 0.4rem; }

/* Year */
.year-card h2 { font-size: 1.05rem; }
.heat-wrap { overflow-x: auto; margin-top: 0.6rem; }
.heat { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; }
.heat i { display: block; border-radius: 3px; background: var(--subtle); }
.heat i.on { background: var(--c); outline: 1px solid rgb(21 22 27 / 0.12); }
.heat i.future { background: none; outline: 1px dashed var(--line); }
.heat i.pad-cell { background: none; }

/* Habits */
.habit-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.habit-edit { border-left: 6px solid var(--c); }
.habit-edit + .habit-edit { margin-top: 0.75rem; }
.habit-edit input { flex: 1; min-width: 0; font-weight: 600; }
.habit-edit .row + .row { margin-top: 0.6rem; }
.swatches { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line-strong); padding: 0; }
.swatch[aria-checked='true'] { box-shadow: 0 0 0 2px var(--ink); }

/* Data */
#view-data h2 { font-size: 1.15rem; }
.toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translate(-50%, 150%);
  background: var(--ink); color: #fff; padding: 0.6rem 1rem; border-radius: 999px; font-weight: 560;
  transition: transform 0.25s; pointer-events: none; max-width: calc(100% - 2rem); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
.foot { text-align: center; padding: 1.25rem 1rem 2rem; }

/* Print: only the month sheet. */
.print-sheet { display: none; }
@media print {
  @page { size: landscape; margin: 10mm; }
  body > *:not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; font: 9pt var(--sans); color: #000; }
  .print-sheet h1 { font-size: 16pt; margin-bottom: 6pt; }
  .print-sheet table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .print-sheet th, .print-sheet td { border: 0.6pt solid #888; height: 22pt; text-align: center; white-space: pre-line; font-weight: 500; }
  .print-sheet thead th { height: auto; padding: 2pt 0; font-size: 7pt; }
  .print-sheet tbody th { width: 26%; text-align: left; padding: 0 4pt; }
  .print-sheet thead th:first-child { width: 26%; }
  .print-sheet td.on { background: #0f766e; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-sheet p { margin-top: 6pt; font-size: 7pt; color: #555; }
}
/* The Habit Tracker template's look (template-sources/habit-tracker-google-sheets/cover.html and build.cjs):
   warm paper with soft teal and amber light, ink #10231f, teal #0f766e, a dark streak card with an amber number,
   and one colour per life area. */
:root {
  --canvas: #fbf8f2;
  --surface: #ffffff;
  --subtle: #f4f7f6;
  --off: #eef3f1;
  --line: #e2e8e6;
  --line-strong: #c9d6d2;
  --ink: #10231f;
  --ink-soft: #3d524d;
  --muted: #6b7f7a;
  --teal: #0f766e;
  --teal-soft: #ccefe5;
  --teal-mid: #5fc4a8;
  --amber: #fbbf24;
  --lime: var(--teal);
  --lime-50: #eaf7f2;
  --shadow: 0 30px 60px -30px rgb(16 35 31 / 0.35);
}
body {
  background:
    radial-gradient(900px 600px at 90% -10%, #d9f4ec 0%, rgb(217 244 236 / 0) 70%),
    radial-gradient(700px 500px at -10% 105%, #fde9c8 0%, rgb(253 233 200 / 0) 70%),
    var(--canvas);
  background-attachment: fixed;
}
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { border-color: var(--ink); }
.card { border-radius: 20px; box-shadow: 0 1px 0 rgb(16 35 31 / 0.03); }
h1 em, h2 em, .appname em { font-style: normal; color: var(--teal); }

.apphead {
  display: flex; align-items: center; gap: 0.75rem; padding: calc(0.75rem + env(safe-area-inset-top)) 1rem 0.5rem;
  max-width: 960px; margin: 0 auto; width: 100%;
}
.appname { display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; font: 800 1.35rem/1 var(--display); letter-spacing: -0.02em; }
.appname img { border-radius: 9px; }
.badge {
  margin-left: auto; display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 600;
  background: var(--surface); color: var(--teal); border: 1px solid #d7e6e1; padding: 0.3rem 0.65rem; border-radius: 999px;
}
.badge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linejoin: round; }

.today-summary { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin-bottom: 0.9rem; }
.today-summary:empty { display: none; }
@media (min-width: 620px) { .today-summary { grid-template-columns: 1fr 1.4fr; } }
.streak-card { background: var(--ink); color: #fff; border-radius: 20px; padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.streak-card .n { font: 800 2.6rem/1 var(--display); color: var(--amber); letter-spacing: -0.03em; }
.streak-card .l { margin-top: 0.35rem; color: #d7e6e1; font-weight: 560; font-size: 0.92rem; overflow-wrap: anywhere; }
.progress-card { padding: 1rem 1.2rem; display: flex; flex-direction: column; justify-content: center; gap: 0.6rem; }
.pct-big { font: 800 1.6rem/1 var(--display); color: var(--teal); }
.bar { height: 12px; border-radius: 999px; background: var(--off); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--teal-mid), var(--teal)); transition: width 0.3s; }

.habit { border-left: 0; border-radius: 20px; position: relative; overflow: hidden; }
.habit::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--c); }
.tick { border-radius: 14px; border-color: #d7e6e1; }
.is-done .tick { color: #fff; }
.dot { border-color: transparent; background: var(--off); border-radius: 8px; }
.dot.on { color: #fff; }
.chip { background: var(--surface); border: 2px solid #d7e6e1; border-style: solid; font-weight: 600; display: inline-flex; align-items: center; gap: 0.45rem; }
.chip i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.chip:hover { border-color: var(--teal); }
.cal-day { border-color: transparent; background: var(--off); }
.cal-day.on { color: #fff; }
.cal-day.is-today { outline-color: var(--teal); }
.month-card, .habit-edit { border-left: 0; position: relative; overflow: hidden; }
.month-card::before, .habit-edit::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--c); }
.heat i { background: var(--off); }
.area-select { min-height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 0.6rem; background: var(--surface); font-weight: 560; }

.tabs { background: rgb(255 255 255 / 0.92); backdrop-filter: blur(8px); }
.tabs button[aria-current='page'] { color: var(--teal); }
.tabs button[aria-current='page'] svg { background: var(--teal-soft); }
@media (min-width: 760px) {
  .tabs { background: transparent; backdrop-filter: none; max-width: 960px; margin: 0 auto; width: 100%; border-bottom: 0; }
  .tabs button[aria-current='page'] { background: var(--teal); color: #fff; }
  .tabs button[aria-current='page'] svg { background: none; }
}

.sheet-link {
  max-width: 928px; margin: 0 auto 0.5rem; width: calc(100% - 2rem); display: flex; gap: 1rem; align-items: center; padding: 0.9rem;
}
.sheet-link img { width: 132px; height: auto; border-radius: 12px; flex: none; border: 1px solid var(--line); }
.sheet-link strong { font-family: var(--display); font-size: 1.05rem; }
.sheet-link p { margin: 0.2rem 0 0.6rem; }
@media (max-width: 420px) { .sheet-link img { width: 96px; } }
.appname, .badge { white-space: nowrap; }
@media (max-width: 400px) { .appname { font-size: 1.2rem; } .badge { font-size: 0.72rem; padding: 0.25rem 0.55rem; } }
