/* ─── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --cell-size: 13px;
  --cell-gap: 3px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 150ms ease;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  /* Light theme */
  --bg:         #ffffff;
  --bg-2:       #f6f8fa;
  --bg-3:       #eef0f3;
  --border:     #d0d7de;
  --text:       #1c2128;
  --text-2:     #57606a;
  --text-3:     #8c959f;
  --cell-empty: #ebedf0;
  --cell-border: rgba(0,0,0,0.06);
  --sidebar-bg: #f6f8fa;
  --shadow:     0 8px 32px rgba(0,0,0,0.12);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.08);
  --overlay:    rgba(0,0,0,0.4);
  --danger:     #ef4444;
}

[data-theme="dark"] {
  --bg:         #0d1117;
  --bg-2:       #161b22;
  --bg-3:       #21262d;
  --border:     #30363d;
  --text:       #e6edf3;
  --text-2:     #8b949e;
  --text-3:     #6e7681;
  --cell-empty: #21262d;
  --cell-border: rgba(255,255,255,0.04);
  --sidebar-bg: #0d1117;
  --shadow:     0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --overlay:    rgba(0,0,0,0.65);
  --danger:     #f87171;
}

html {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100%;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Auth ──────────────────────────────────────────────────────────────── */
#auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.auth-panel {
  width: 100%;
  max-width: 390px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
}

.auth-panel h1 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 650;
}

.auth-status {
  min-height: 20px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.auth-status.error { color: var(--danger); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-help {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}

.auth-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-actions .btn { flex: 1; justify-content: center; }

.auth-secondary-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.auth-secondary-actions button {
  border: 0;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.auth-secondary-actions button:hover { color: var(--text); }

.account-email {
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}

/* ─── Layout ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.brand-icon {
  width: 20px;
  height: 20px;
  color: var(--text-2);
}

#habit-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#habit-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

#habit-list li:hover { background: var(--bg-3); color: var(--text); }
#habit-list li.active { background: var(--bg-3); color: var(--text); font-weight: 500; }

.habit-list-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.sidebar-add-btn svg { width: 16px; height: 16px; }
.sidebar-add-btn:hover { background: var(--bg-3); color: var(--text); }

/* ─── Habit Indicator (dot or emoji) ───────────────────────────────────── */
.habit-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  line-height: 1;
  overflow: hidden;
}

/* Sizes */
.habit-indicator-sm {
  width: 28px;
  height: 28px;
  font-size: 19px;
}

.habit-indicator-md {
  width: 34px;
  height: 34px;
  font-size: 23px;
}

/* Main header indicator */
#habit-indicator {
  width: 38px;
  height: 38px;
  font-size: 26px;
}

/* Mobile tab dot */
.mobile-tab-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 19px;
  flex-shrink: 0;
  line-height: 1;
}

/* ─── Main ──────────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ─── Empty State ───────────────────────────────────────────────────────── */
#empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}

.empty-content { text-align: center; max-width: 320px; }
.empty-icon { margin: 0 auto 24px; width: 72px; height: 72px; color: var(--text-3); }
.empty-icon svg { width: 100%; height: 100%; }
.empty-content h2 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.empty-content p { font-size: 14px; color: var(--text-2); line-height: 1.6; margin-bottom: 28px; }

/* ─── Mobile Header ─────────────────────────────────────────────────────── */
#mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.mobile-header-actions { display: flex; align-items: center; gap: 8px; }

#mobile-tabs-bar {
  display: none;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 8px 4px 8px 12px;
  gap: 4px;
}

#mobile-tabs-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
#mobile-tabs-scroll::-webkit-scrollbar { display: none; }
#mobile-habit-tabs { display: flex; gap: 6px; padding-right: 4px; width: max-content; }

.mobile-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px 6px 8px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.mobile-tab.active { color: var(--text); border-color: transparent; background: var(--bg-3); }
.mobile-add-btn { flex-shrink: 0; width: 36px; height: 36px; }

/* ─── Habit View & Header ───────────────────────────────────────────────── */
#habit-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#habit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 0;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
}

.habit-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }

#habit-name-display {
  font-size: 20px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.unit-badge {
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.habit-header-right { display: flex; align-items: center; gap: 8px; }

.year-nav { display: flex; align-items: center; gap: 4px; }
#year-display { font-size: 14px; font-weight: 500; color: var(--text-2); min-width: 40px; text-align: center; }

/* ─── Stats ─────────────────────────────────────────────────────────────── */
#stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 20px 28px 0;
  flex-shrink: 0;
}

.stat-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; }
.stat-value { font-size: 20px; font-weight: 600; color: var(--text); line-height: 1.2; margin-bottom: 4px; }
.stat-label { font-size: 11.5px; color: var(--text-3); line-height: 1.3; }

/* ─── Stopwatch Section ─────────────────────────────────────────────────── */
#stopwatch-section {
  flex-shrink: 0;
  margin: 16px 28px 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.stopwatch-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.stopwatch-left { display: flex; flex-direction: column; gap: 6px; }

.stopwatch-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
}

.stopwatch-icon { width: 14px; height: 14px; flex-shrink: 0; }
.stopwatch-label { font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

.stopwatch-habit-badge {
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stopwatch-habit-badge:empty { display: none; }

.timer-display {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  line-height: 1;
}

.timer-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.timer-btn {
  min-height: 38px;
  padding: 7px 16px;
  font-size: 13.5px;
  gap: 6px;
}

.timer-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ─── Calendar ──────────────────────────────────────────────────────────── */
#calendar-container {
  flex: 1;
  overflow: hidden;
  padding: 20px 28px 12px;
  min-height: 0;
}

#calendar-scroll-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#calendar-scroll-wrap::-webkit-scrollbar { height: 6px; }
#calendar-scroll-wrap::-webkit-scrollbar-track { background: transparent; }
#calendar-scroll-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#month-labels { position: relative; height: 20px; margin-left: 28px; }

.month-label { position: absolute; font-size: 11px; color: var(--text-3); user-select: none; }

#calendar-body { display: flex; gap: 4px; align-items: flex-start; }

#day-labels {
  display: grid;
  grid-template-rows: repeat(7, var(--cell-size));
  gap: var(--cell-gap);
  padding-top: 2px;
  flex-shrink: 0;
  width: 24px;
}

#day-labels span {
  font-size: 10px;
  color: var(--text-3);
  text-align: right;
  line-height: var(--cell-size);
  padding-right: 4px;
  user-select: none;
}

#calendar-weeks { display: flex; gap: var(--cell-gap); align-items: flex-start; }

.cal-week { display: grid; grid-template-rows: repeat(7, var(--cell-size)); gap: var(--cell-gap); flex-shrink: 0; }

.cal-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 2.5px;
  cursor: pointer;
  transition: transform 0.1s ease;
  background: var(--cell-empty);
  border: 1px solid var(--cell-border);
  position: relative;
}

.cal-cell.out-of-year { background: transparent; border-color: transparent; cursor: default; pointer-events: none; }
.cal-cell.future { opacity: 0.35; cursor: default; }
.cal-cell.today { box-shadow: 0 0 0 1.5px var(--text-2); }
.cal-cell:not(.out-of-year):not(.future):hover { transform: scale(1.35); z-index: 2; }

/* ─── Today Add Slider ──────────────────────────────────────────────────── */
#today-add-panel {
  flex-shrink: 0;
  margin: 0 28px 24px;
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.today-add-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

#today-add-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}

#today-add-value {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 24px;
  line-height: 1;
}

.today-add-slider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

#today-add-slider {
  width: 100%;
  height: 34px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

#today-add-slider::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border);
}

#today-add-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 34px;
  height: 34px;
  margin-top: -13px;
  border-radius: 50%;
  background: var(--text);
  border: 4px solid var(--bg);
  box-shadow: var(--shadow-sm);
}

#today-add-slider::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border);
}

#today-add-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--text);
  border: 4px solid var(--bg);
  box-shadow: var(--shadow-sm);
}

#today-add-error { margin-top: 10px; }

/* ─── Tooltip ───────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: 12.5px;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity 0.12s ease;
  line-height: 1.5;
}
#tooltip.visible { opacity: 1; }

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  font-family: var(--font);
  white-space: nowrap;
  min-height: 40px;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { opacity: 0.85; }

.btn-ghost { background: none; color: var(--text-2); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg-3); }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

/* ─── Theme Icons ───────────────────────────────────────────────────────── */
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ─── Modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-overlay.open { pointer-events: auto; opacity: 1; }

.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); cursor: pointer; }

.modal-sheet {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: translateY(8px) scale(0.98);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal-sheet { transform: translateY(0) scale(1); }
.modal-sheet-sm { max-width: 340px; }

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 0; flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }

.modal-footer {
  padding: 0 20px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.modal-footer-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

/* ─── Form Inputs ───────────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 8px; }

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-optional {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  background: var(--bg-3);
  border-radius: 4px;
  padding: 1px 6px;
}

.input-group input[type="text"],
.input-group input[type="number"],
.input-group input[type="date"],
.input-group input[type="email"],
.input-group input[type="password"],
.input-group select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
.input-group input:focus, .input-group select:focus { border-color: var(--text-2); }

.input-group input.input-invalid { border-color: var(--danger); }

.input-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}

.input-error {
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.4;
}

/* ─── Color Palette ─────────────────────────────────────────────────────── */
.color-palette { display: flex; flex-wrap: wrap; gap: 10px; }

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); transform: scale(1.15); }

/* ─── Emoji Input ───────────────────────────────────────────────────────── */
.emoji-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emoji-text-input {
  width: 72px !important;
  font-size: 22px !important;
  text-align: center;
  padding: 6px 10px !important;
  flex-shrink: 0;
}

.emoji-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.emoji-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-2);
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition), transform 0.1s ease;
  flex-shrink: 0;
}
.emoji-btn:hover { background: var(--bg-3); border-color: var(--text-3); transform: scale(1.1); }

/* ─── Unit Switcher ─────────────────────────────────────────────────────── */
.unit-switcher-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.unit-switcher-label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
}

.unit-switcher {
  display: flex;
  background: var(--bg-3);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
}

.unit-btn {
  padding: 5px 18px;
  border: none;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 17px;
  transition: all var(--transition);
  font-family: var(--font);
}
.unit-btn.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.15); }

/* ─── Activity Presets ──────────────────────────────────────────────────── */
.presets-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.presets { display: flex; flex-wrap: wrap; gap: 8px; }

.preset-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.preset-btn:hover { background: var(--bg-3); border-color: var(--text-3); color: var(--text); }

/* ─── Timer Save Modal ──────────────────────────────────────────────────── */
.timer-save-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timer-save-big {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}

.timer-save-meta {
  font-size: 13px;
  color: var(--text-2);
}

/* ─── Confirm ───────────────────────────────────────────────────────────── */
.confirm-text { font-size: 14px; color: var(--text-2); line-height: 1.6; }

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Tablet ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #stats-grid { grid-template-columns: repeat(3, 1fr); }
  .timer-display { font-size: 28px; }
}

/* ─── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root { --cell-size: 11px; --cell-gap: 2px; }

  #sidebar { display: none; }
  #mobile-header { display: flex; }
  #mobile-tabs-bar { display: flex; }

  #habit-header { padding: 16px 16px 0; }
  #habit-name-display { font-size: 17px; max-width: 180px; }

  #stats-grid { grid-template-columns: repeat(2, 1fr); padding: 16px 16px 0; gap: 8px; }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 17px; }
  .stat-label { font-size: 11px; }

  #stopwatch-section { margin: 12px 16px 0; padding: 14px 16px; }
  .stopwatch-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
  .timer-display { font-size: 32px; }
  .timer-controls { width: 100%; }
  .timer-btn { flex: 1; justify-content: center; min-height: 44px; }

  #calendar-container { padding: 16px; flex: 1; overflow: hidden; }
  #today-add-panel { margin: 0 16px 16px; padding: 14px 16px; }
  .today-add-slider-row { grid-template-columns: 1fr; gap: 10px; }
  #today-add-btn { justify-content: center; }

  .modal-overlay { align-items: flex-end; padding: 0; padding-bottom: env(safe-area-inset-bottom); }
  .modal-sheet { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-width: 100%; max-height: 85vh; transform: translateY(20px); }
  .modal-overlay.open .modal-sheet { transform: translateY(0); }

  .btn { min-height: 44px; }
  .icon-btn { width: 40px; height: 40px; }
  #auth-screen { align-items: flex-start; }
  .auth-actions { flex-direction: column; }
  .auth-actions .btn { width: 100%; }
}

/* ─── Utility ───────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

body, .stat-card, .sidebar-brand, #habit-list li, .unit-badge {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
