*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --radius: 14px;
  --radius-sm: 9px;

  /* surfaces */
  --bg: #0f0f0f;
  --bg-inset: #111111;
  --card-bg: #1a1a1a;
  --surface-2: #161616;
  --surface-raised: #1c1c1c;
  --surface-3: #222222;
  --surface-active: #262626;
  --surface-missed: #252525;

  /* borders */
  --card-border: #2a2a2a;
  --border-strong: #333333;
  --border-stronger: #444444;
  --border-faint: #1f1f1f;
  --track-bg: #2a2a2a;

  /* text */
  --text: #f0f0f0;
  --text-muted: #888888;
  --text-dim: #4a4a4a;
  --text-faint: #666666;
  --text-faint2: #555555;

  /* brand / accent (consistent across themes) */
  --accent: #22c55e;
  --accent-bright: #4ade80;
  --on-accent: #0a1f0a;
  --streak: #f97316;
  --planned: rgba(255, 255, 255, 0.75);

  /* status */
  --danger: #f87171;
  --danger-bg: #1f0d0d;
  --danger-bg-hover: #2a1111;
  --danger-border: #3a1414;
  --info: #60a5fa;

  /* chart chrome */
  --chart-line: rgba(255, 255, 255, 0.28);
  --chart-dot: rgba(255, 255, 255, 0.5);
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-inset: #e9ebef;
  --card-bg: #ffffff;
  --surface-2: #ffffff;
  --surface-raised: #eef0f3;
  --surface-3: #eceef2;
  --surface-active: #e1e4ea;
  --surface-missed: #e7e9ee;

  --card-border: #e3e6eb;
  --border-strong: #d3d7df;
  --border-stronger: #c3c8d2;
  --border-faint: #edeff3;
  --track-bg: #e3e6eb;

  --text: #1a1d23;
  --text-muted: #5c6470;
  --text-dim: #aab0bb;
  --text-faint: #868d99;
  --text-faint2: #98a0ac;

  --on-accent: #08220d;
  --planned: rgba(0, 0, 0, 0.42);

  --danger-bg: #fdecec;
  --danger-bg-hover: #fadfe0;
  --danger-border: #f3cccd;

  --chart-line: rgba(0, 0, 0, 0.3);
  --chart-dot: rgba(0, 0, 0, 0.45);
}

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Native-app feel (also applies in the Capacitor wrap) */
  overscroll-behavior: none;                 /* no scroll-chaining / pull-to-refresh glow */
  -webkit-tap-highlight-color: transparent;  /* no grey tap flash (inherited) */
  -webkit-touch-callout: none;               /* no long-press callout menu */
  -webkit-user-select: none;                 /* UI chrome isn't selectable… */
  user-select: none;
  touch-action: manipulation;                /* kill double-tap-zoom delay */
}

/* …but keep real text entry and the logged history selectable/copyable */
input, textarea, select, [contenteditable],
.log-list, .log-item, .log-value, .log-date {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 28px 16px calc(64px + env(safe-area-inset-bottom, 0px) + 20px);
}

/* ── Global header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 20px;
}

.app-logo {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
}

/* Balances the header gear so the centered logo stays centered */
.header-spacer {
  width: 36px;
  flex-shrink: 0;
}

.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.header-icon-btn:hover {
  color: var(--text);
  border-color: var(--border-stronger);
  background: var(--surface-3);
}

.header-icon-btn:active {
  transform: scale(0.93);
}

/* keep .settings-btn working as an alias */
.settings-btn { /* no extra rules needed — uses .header-icon-btn */ }

/* ── Cards ── */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.card.expanded {
  border-color: var(--border-strong);
}

/* ── Card Header ── */
.card-header {
  padding: 16px 16px 0;
  cursor: pointer;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.card-header:focus-visible {
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 0 0 2px var(--accent) inset;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-title-row h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: var(--card-border);
  color: var(--text-dim);
  transition: background 0.3s, color 0.3s;
}

.status-badge.status-ahead {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent);
}

.status-badge.status-on-track {
  background: rgba(59, 130, 246, 0.15);
  color: var(--info);
}

.status-badge.status-behind {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.card-value-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.current-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
  color: var(--text);
  transition: color 0.3s;
}

.current-value.loading {
  color: var(--text-dim);
}

.chevron {
  color: var(--text-muted);
  transition: transform 0.3s ease, color 0.2s;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.card.expanded .chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

/* ── Progress Bar ── */
.progress-section {
  padding: 0 16px;
  margin-bottom: 14px;
}

.progress-track {
  position: relative;
  height: 8px;
  background: var(--track-bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.planned-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--planned);
  z-index: 2;
  transition: left 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Log Input ── */
.log-input-row {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

.log-input {
  flex: 1;
  background: var(--bg-inset);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.log-input:focus {
  border-color: var(--accent);
}

.log-input::placeholder {
  color: var(--text-dim);
}

.log-input::-webkit-outer-spin-button,
.log-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.log-input[type=number] {
  -moz-appearance: textfield;
}

.log-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.1px;
}

.log-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.log-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.log-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Expandable Details ── */
.card-details-outer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.card.expanded .card-details-outer {
  grid-template-rows: 1fr;
}

.card-details {
  overflow: hidden;
  min-height: 0;
}

.card-details-inner {
  border-top: 1px solid var(--card-border);
  padding: 16px 16px 20px;
  opacity: 0;
  transition: opacity 0.2s ease 0.05s;
}

.card.expanded .card-details-inner {
  opacity: 1;
}

/* ── Chart ── */
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 200px;
  margin-bottom: 16px;
}

/* ── Log List ── */
.log-list {
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.log-list::-webkit-scrollbar {
  width: 4px;
}

.log-list::-webkit-scrollbar-track {
  background: transparent;
}

.log-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

.log-list-header {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid rgba(42, 42, 42, 0.6);
  font-size: 14px;
}

.log-item:last-child {
  border-bottom: none;
}

.log-date {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.log-value {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.empty-state {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px 0 8px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  padding: 11px 22px;
  border-radius: 100px;
  white-space: nowrap;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-success {
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--accent-bright);
}

.toast.toast-error {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

/* ── Loading Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, var(--border-faint) 25%, var(--card-border) 50%, var(--border-faint) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Settings overlay ── */
.settings-overlay {
  position: fixed;
  inset: 0;
  display: none; /* toggled to flex by JS */
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  z-index: 300;
  transition: background 0.3s ease;
}

.settings-overlay.open {
  background: rgba(0, 0, 0, 0.65);
}

/* ── Settings panel (bottom sheet) ── */
.settings-panel {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: dark;
}

.settings-overlay.open .settings-panel {
  transform: translateY(0);
}

.settings-drag-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

/* ── Settings header ── */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--surface-3);
  flex-shrink: 0;
}

.settings-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.settings-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--card-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.settings-close-btn:hover {
  background: var(--border-strong);
  color: var(--text);
}

/* ── Settings body ── */
.settings-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.settings-body::-webkit-scrollbar { width: 4px; }
.settings-body::-webkit-scrollbar-track { background: transparent; }
.settings-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.settings-section {
  padding: 16px 20px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.settings-divider {
  height: 1px;
  background: var(--surface-3);
  margin: 0 20px;
}

/* ── Settings fields ── */
.settings-field {
  margin-bottom: 14px;
}

.settings-field:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.settings-input-group {
  display: flex;
  align-items: center;
  background: var(--bg-inset);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s;
}

.settings-input-group:focus-within {
  border-color: var(--accent);
}

.settings-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 16px;
  padding: 10px 12px;
  outline: none;
  min-width: 0;
}

.settings-input::placeholder {
  color: var(--text-dim);
}

.settings-input::-webkit-outer-spin-button,
.settings-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.settings-input[type=number] {
  -moz-appearance: textfield;
}

/* Standalone date input (no group wrapper) */
.settings-input--date {
  display: block;
  width: 100%;
  background: var(--bg-inset);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s;
  color-scheme: dark;
}

.settings-input--date:focus {
  border-color: var(--accent);
}

.settings-unit {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 0 12px 0 4px;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

/* Proportional hint button */
.proportional-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 20px;
  padding: 2px 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  letter-spacing: 0.2px;
}

.proportional-btn:hover {
  background: rgba(34, 197, 94, 0.18);
}

.proportional-btn:active {
  transform: scale(0.95);
}

/* ── Settings footer ── */
.settings-footer {
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--surface-3);
  flex-shrink: 0;
}

.settings-save-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  padding: 13px;
  cursor: pointer;
  letter-spacing: 0.1px;
  transition: opacity 0.15s, transform 0.1s;
}

.settings-save-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.settings-save-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.settings-save-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Notification toggle button ── */
.settings-notif-btn {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.1px;
  transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.15s;
}

.settings-notif-btn:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.08);
}

.settings-notif-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.settings-notif-btn:disabled {
  cursor: default;
}

.settings-notif-btn--active {
  color: var(--text-muted);
  border-color: var(--card-border);
  opacity: 0.7;
}

.settings-notif-btn--disabled {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
  opacity: 0.7;
}

/* ── Notification toggle (on/off switch) ── */
.notif-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-label--inline {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.notif-toggle {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 26px;
  cursor: pointer;
  flex-shrink: 0;
}

.notif-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.notif-toggle-track {
  width: 100%;
  height: 100%;
  background: var(--card-border);
  border-radius: 13px;
  transition: background 0.2s;
  position: relative;
}

.notif-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--text-faint);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.notif-toggle input:checked + .notif-toggle-track {
  background: var(--accent);
}

.notif-toggle input:checked + .notif-toggle-track::after {
  background: var(--text);
  transform: translateX(18px);
}

/* ── Weekday picker ── */
.notif-weekdays {
  display: flex;
  gap: 5px;
}

.weekday-btn {
  flex: 1;
  padding: 7px 2px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  background: var(--bg-inset);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
}

.weekday-btn--active {
  background: rgba(34, 197, 94, 0.12);
  color: var(--accent);
  border-color: rgba(34, 197, 94, 0.4);
}

/* ── Auth pages (login / register) ── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 36px 28px 28px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  margin: 0 auto 20px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  text-align: center;
  color: var(--text);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 28px;
}

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

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.auth-input {
  background: var(--bg-inset);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-input::placeholder {
  color: var(--text-dim);
}

.auth-error {
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--danger);
  margin: 0;
}

.auth-submit-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  padding: 13px;
  cursor: pointer;
  letter-spacing: 0.1px;
  margin-top: 4px;
  transition: opacity 0.15s, transform 0.1s;
}

.auth-submit-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.auth-submit-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.auth-submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.auth-footer-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.15s;
}

.auth-link:hover {
  opacity: 0.75;
}

.auth-link--dim {
  color: var(--text-muted);
}

/* ── Tab views ── */
.tab-view--hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#view-progress:not(.tab-view--hidden),
#view-habits:not(.tab-view--hidden) {
  animation: fadeIn 0.2s ease;
}

/* ── Bottom navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card-bg);
  border-top: 0.5px solid var(--card-border);
  display: flex;
  align-items: stretch;
  z-index: 200;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  border-top: 2px solid transparent;
  color: var(--text-faint2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding-top: 2px;
  transition: color 0.2s, border-top-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.nav-tab--active {
  color: var(--accent);
  border-top-color: var(--accent);
}

.nav-divider {
  width: 0.5px;
  background: var(--card-border);
  align-self: stretch;
}

/* ── Habits section ── */
.habits-section {
  display: flex;
  flex-direction: column;
}

.add-habit-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  padding: 13px;
  cursor: pointer;
  letter-spacing: 0.3px;
  margin-top: 14px;
  transition: opacity 0.15s;
}

.add-habit-btn:hover {
  opacity: 0.88;
}

.add-habit-btn:active {
  transform: scale(0.98);
}

.habits-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.habits-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 32px 0 8px;
  line-height: 1.6;
}

.habits-empty strong {
  color: var(--text-muted);
}

/* ── Habit card ── */
.habit-card {
  background: var(--card-bg);
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.habit-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.habit-card-header:focus-visible {
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 0 0 2px var(--accent) inset;
}

.habit-header-content {
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}

.habit-chevron {
  color: var(--text-muted);
  transition: transform 0.3s ease, color 0.2s;
  flex-shrink: 0;
  margin-top: 2px;
}

.habit-card.expanded .habit-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.habit-body-outer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.habit-card.expanded .habit-body-outer {
  grid-template-rows: 1fr;
}

.habit-body-inner {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  transition: opacity 0.2s ease 0.05s;
}

.habit-card.expanded .habit-body-inner {
  opacity: 1;
}

.habit-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}

.habit-streak {
  font-size: 11px;
  font-weight: 500;
  color: var(--streak);
}

.habit-sep {
  height: 0.5px;
  background: var(--surface-3);
}

.habit-cal {
  padding: 12px 16px 8px;
}

.habit-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  padding: 0 16px 10px;
}

.habit-actions {
  display: flex;
  border-top: 0.5px solid var(--surface-3);
}

.habit-edit-row,
.habit-delete-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 500;
  padding: 11px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.habit-edit-row {
  color: var(--text-muted);
  border-right: 0.5px solid var(--surface-3);
}

.habit-edit-row:hover {
  background: var(--surface-raised);
}

.habit-delete-row {
  color: var(--danger);
}

.habit-delete-row:hover {
  background: var(--danger-bg-hover);
}

/* ── Habit calendar ── */
.cal-month-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-dow {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-faint);
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 400;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: default;
}

.cal-cell--done {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  cursor: pointer;
}

.cal-cell--missed {
  background: var(--surface-missed);
  color: var(--text-faint);
  cursor: pointer;
}

.cal-cell--today {
  background: transparent;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  cursor: pointer;
}

.cal-cell--future {
  background: transparent;
  color: var(--border-stronger);
}

.cal-cell--empty {
  background: transparent;
}

.cal-cell--done:active,
.cal-cell--missed:active,
.cal-cell--today:active {
  transform: scale(0.88);
  transition: transform 0.1s;
}

/* ── Add Habit modal ── */
.habit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  padding: 20px;
  transition: background 0.2s ease;
  pointer-events: none;
}

.habit-modal-overlay.open {
  background: rgba(0, 0, 0, 0.65);
  pointer-events: auto;
}

.habit-modal-card {
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 360px;
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: scale(0.94) translateY(8px);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.habit-modal-overlay.open .habit-modal-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.habit-modal-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  margin-bottom: 16px;
}

.habit-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.habit-modal-cancel {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.habit-modal-cancel:hover {
  background: var(--card-border);
}

.habit-modal-save {
  flex: 1;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  padding: 11px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.habit-modal-save:hover:not(:disabled) {
  opacity: 0.88;
}

.habit-modal-save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Habit modal form fields ── */
.habit-modal-field {
  margin-bottom: 16px;
}

.habit-modal-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

.habit-modal-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 5px;
}

/* ── Emoji picker ── */
.emoji-picker {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.emoji-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.emoji-cell:hover {
  background: var(--surface-3);
}

.emoji-cell--selected {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.1);
}

/* ── Weekly goal ── */
.habit-week-goal {
  margin-top: 8px;
}

.habit-week-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.habit-week-bar {
  height: 6px;
  background: var(--card-border);
  border-radius: 3px;
  overflow: hidden;
}

.habit-week-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
  min-width: 0;
}

/* ============================================================
   TRACKERS (generic progress goals)
   ============================================================ */
.add-tracker-btn {
  display: block;
  width: 100%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  padding: 13px;
  cursor: pointer;
  letter-spacing: 0.3px;
  margin-top: 14px;
  transition: opacity 0.15s;
}

.add-tracker-btn:hover { opacity: 0.88; }
.add-tracker-btn:active { transform: scale(0.98); }

#cards-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cards-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 32px 0 8px;
  line-height: 1.6;
}

.cards-empty strong { color: var(--text-muted); }

/* ── Tracker card edit/delete actions ── */
.tracker-actions {
  display: flex;
  border-top: 0.5px solid var(--surface-3);
  margin-top: 4px;
}

.tracker-edit-row,
.tracker-delete-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 500;
  padding: 11px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tracker-edit-row {
  color: var(--text-muted);
  border-right: 0.5px solid var(--surface-3);
}

.tracker-edit-row:hover { background: var(--surface-raised); }

.tracker-delete-row { color: var(--danger); }
.tracker-delete-row:hover { background: var(--danger-bg-hover); }

/* ── Tracker modal extras ── */
.tracker-modal-row {
  display: flex;
  gap: 10px;
}

.tracker-modal-row .habit-modal-field {
  flex: 1;
  min-width: 0;
}

.tracker-reminder-block {
  border-top: 0.5px solid var(--card-border);
  padding-top: 14px;
  margin-top: 4px;
}

.tracker-modal-delete {
  display: block;
  width: 100%;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  padding: 10px;
  margin-top: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.tracker-modal-delete:hover { background: var(--danger-bg-hover); }

/* ============================================================
   GOAL ↔ HABIT: insight line + modal chips
   ============================================================ */
.goal-insight {
  margin-top: 10px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  padding: 7px 10px;
  border-radius: 8px;
}

.goal-insight--good { color: var(--accent); background: rgba(34, 197, 94, 0.10); }
.goal-insight--warn { color: var(--danger); background: rgba(248, 113, 113, 0.10); }
.goal-insight--info { color: var(--info); background: rgba(96, 165, 250, 0.10); }

/* Contributing-habit chips in the goal modal */
.goal-habits-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.goal-habits-empty {
  font-size: 12px;
  color: var(--text-dim);
}

.goal-habit-chip {
  background: var(--surface-raised);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.goal-habit-chip--on {
  background: rgba(34, 197, 94, 0.14);
  border-color: var(--accent);
  color: var(--accent);
}

.goal-habit-new {
  display: flex;
  gap: 6px;
}

.goal-habit-new .auth-input { flex: 1; min-width: 0; }
.goal-habit-new-goal { flex: 0 0 78px !important; text-align: center; }

.goal-habit-new-btn {
  flex: 0 0 auto;
  background: var(--surface-3);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 0 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.goal-habit-new-btn:hover:not(:disabled) { background: var(--card-border); }
.goal-habit-new-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   SETTINGS SCREEN (full-screen slide-in from the header gear)
   ============================================================ */
.settings-screen {
  position: fixed;
  inset: 0;
  margin: 0 auto;
  max-width: 480px;
  background: var(--bg);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  transform: translateX(-100%); /* slides in from the left (matches the gear's position) */
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-screen[hidden] { display: none; }   /* keep hidden until opened (overrides display:flex) */
.settings-screen.open { transform: translateX(0); }

.settings-screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
}

.settings-screen-title {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text);
}

.settings-screen-body { flex: 1; }

.settings-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 18px 4px 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.settings-row:hover { background: var(--surface-3); }
.settings-row:active { background: var(--surface-active); }
.settings-row svg { color: var(--text-dim); flex-shrink: 0; }

.settings-row { margin-bottom: 8px; }   /* spacing between consecutive rows */
.settings-row[hidden] { display: none; } /* `hidden` must win over display:flex */

.settings-email {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 6px;
  word-break: break-all;
}

/* Non-tappable rows (hold a toggle / segmented control) */
.settings-row--static,
.settings-row--static:hover,
.settings-row--static:active { cursor: default; background: var(--card-bg); }

.settings-row--accent {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.settings-row--accent svg { color: var(--accent); }
.settings-row--accent:hover { background: rgba(34, 197, 94, 0.18); }

.settings-row--danger { color: var(--danger); }
.settings-row--danger svg { color: var(--danger); }
.settings-row--danger:hover { background: var(--danger-bg); }

.settings-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(34, 197, 94, 0.15);
  padding: 3px 10px;
  border-radius: 20px;
}

/* Theme segmented control */
.theme-seg {
  display: flex;
  gap: 4px;
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.theme-opt {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.theme-opt--on {
  background: var(--card-bg);
  color: var(--text);
}

.settings-version {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 28px 0 8px;
}
