:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #101114);
  --hint: var(--tg-theme-hint-color, #8b8f96);
  --card: var(--tg-theme-secondary-bg-color, #f1f2f4);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e05252;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  padding: 16px 16px 96px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }
.hint { color: var(--hint); font-size: 14px; margin: 2px 0 0; }
.empty { text-align: center; margin-top: 32px; }

.head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.head-text h1 { font-size: 22px; margin: 0; }

.ring { width: 72px; height: 72px; flex: none; transform: rotate(-90deg); }
.ring-bg, .ring-line { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--card); }
.ring-line {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 189;
  stroke-dashoffset: 189;
  transition: stroke-dashoffset .3s ease;
}

.week { display: flex; gap: 6px; margin-bottom: 18px; }
.week-day {
  flex: 1; text-align: center; padding: 6px 0; border-radius: 10px;
  background: var(--card); font-size: 12px; color: var(--hint);
}
.week-day.done { background: var(--accent); color: var(--accent-text); }
.week-day.today { outline: 2px solid var(--accent); }

.section-title { font-size: 14px; color: var(--hint); margin: 22px 0 8px; font-weight: 600; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.habit {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: var(--card);
}
.habit-emoji { font-size: 22px; }
.habit-body { flex: 1; min-width: 0; }
.habit-title { font-weight: 600; }
.habit-title.done { text-decoration: line-through; opacity: .55; }
.habit-sub { font-size: 13px; color: var(--hint); }
.habit-check {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  border: 2px solid var(--hint); background: none; color: var(--accent-text);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.habit-check.done { background: var(--accent); border-color: var(--accent); }
.habit-stats-btn { background: none; border: none; color: var(--hint); font-size: 18px; cursor: pointer; }

.fab {
  position: fixed; right: 18px; bottom: 24px; width: 56px; height: 56px;
  border: none; border-radius: 50%; background: var(--accent);
  color: var(--accent-text); font-size: 30px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}

.gate {
  position: fixed; inset: 0; display: flex; align-items: center;
  justify-content: center; padding: 32px; background: var(--bg);
  text-align: center; color: var(--hint);
}

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 6px; }
.field input[type="text"], .field input[type="number"], .field input[type="time"] {
  width: 100%; padding: 12px; border-radius: 12px; border: none;
  background: var(--card); color: var(--text); font-size: 16px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border-radius: 10px; border: none;
  background: var(--card); color: var(--text); font-size: 15px; cursor: pointer;
}
.chip.on { background: var(--accent); color: var(--accent-text); }
.btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: var(--accent); color: var(--accent-text); font-size: 16px;
  font-weight: 600; cursor: pointer; margin-top: 8px;
}
.btn.ghost { background: var(--card); color: var(--text); }
.btn.danger { background: none; color: var(--danger); }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--hint); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-head { font-size: 11px; color: var(--hint); text-align: center; }
.cal-day {
  aspect-ratio: 1; border-radius: 8px; background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--hint);
}
.cal-day.scheduled { outline: 1px solid var(--hint); }
.cal-day.done { background: var(--accent); color: var(--accent-text); outline: none; }
.cal-day.blank { background: none; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
