:root {
  --color-primary: #1a1a1a;
  --color-primary-hover: #000000;
  --color-danger: #555555;
  --color-danger-hover: #333333;
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-border: #e5e5e5;
  --color-text: #1a1a1a;
  --color-text-muted: #888888;
  --color-success: #1a1a1a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

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

html {
  overflow-x: hidden;
  overscroll-behavior-x: none;
  width: 100%;
}

body {
  width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
  max-width: 100vw;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.app-logo {
  width: 78px;
  height: 78px;
  border-radius: 12px;
}
.app-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: #1a1a1a;
  line-height: 1.2;
}
.tagline {
  color: var(--color-text-muted);
  font-size: 12px;
}

/* Date Navigation */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 4px;
}
.date-nav .btn-outline {
  border: none;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--color-text-muted);
  box-shadow: none;
}
.date-display {
  text-align: center;
}
.date-display h2 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}
.date-full {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-align: center;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-outline {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-outline:hover { background: var(--color-bg); }
.btn-outline.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.btn-block {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 16px;
  margin-bottom: 24px;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-danger {
  background: var(--color-danger);
  color: #fff;
}
.btn-danger:hover { background: var(--color-danger-hover); }

/* Flash */
.flash-notice {
  background: #fafafa;
  color: #1a1a1a;
  border: 1px solid #e5e5e5;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  animation: flash-dismiss 5s ease-in-out forwards;
}
@keyframes flash-dismiss {
  0%, 80% { opacity: 1; max-height: 100px; margin-bottom: 16px; padding: 10px 14px; }
  100% { opacity: 0; max-height: 0; margin-bottom: 0; padding: 0 14px; overflow: hidden; pointer-events: none; }
}
.fasting-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}
.fasting-icon { font-size: 20px; flex-shrink: 0; }
.fasting-text strong { display: block; font-weight: 700; }

/* Fasting Timer */
.fasting-timer-details {
  background: #fefcf5;
  border: 1px solid #ede8d8;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.fasting-timer-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.fasting-timer-summary::-webkit-details-marker { display: none; }
.fasting-timer-summary::marker { display: none; content: ""; }
.fasting-timer-summary:focus { outline: none; }
.fasting-elapsed-inline {
  margin-left: auto;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.fasting-timer-details[open] .fasting-elapsed-inline {
  display: none;
}
.fasting-timer-body {
  padding: 0 14px 12px;
  text-align: center;
}
.fasting-timer-details[open] .fasting-timer-summary {
  margin-bottom: 0;
}
.fasting-elapsed {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  display: block;
  transition: color 0.3s;
}
.fasting-last-meal {
  font-size: 12px;
  color: #92400e;
  opacity: 0.8;
  display: block;
  margin-top: 2px;
}
.fasting-milestone-12 { color: #1a1a1a; }
.fasting-milestone-16 { color: #1a1a1a; }
.fasting-milestone-18 { color: #1a1a1a; }
.fasting-milestone-24 { color: #1a1a1a; }

/* Activity Groups */
.view-tabs {
  display: flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.view-tab {
  flex: 1;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  border-right: 1px solid var(--color-border);
}
.view-tab:last-child { border-right: none; }
.view-tab.active {
  color: #1a1a1a;
  background: rgba(0, 0, 0, 0.05);
  border-bottom: 2px solid #1a1a1a;
}
.view-tab:not(.active):hover {
  background: var(--color-bg);
}
.timeline-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border);
}
.timeline-row:last-child { border-bottom: none; }
.timeline-time {
  flex-shrink: 0;
  width: 44px;
  text-align: center;
  padding-top: 2px;
}
.timeline-hour {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}
.timeline-ampm {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.timeline-emoji {
  flex-shrink: 0;
  width: 28px;
  text-align: center;
  font-size: 18px;
  padding-top: 2px;
}
.timeline-card {
  flex: 1;
  min-width: 0;
}
.timeline-row .activity-card {
  border: none;
  padding: 0;
  margin: 0;
  background: none;
}
.timeline-row .activity-card-compact {
  padding: 0;
}
.timeline-action {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  color: #ccc;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  align-self: flex-start;
  margin-top: 2px;
}
.timeline-action:hover {
  color: #555;
}
.timeline-delete {
  color: #e08080;
}
.timeline-delete:hover {
  color: #c44;
}
.timeline-repeat {
  display: inline-flex;
  align-items: center;
  color: #4abe4a;
}
.timeline-repeat:hover {
  color: #2d8a2d;
}
.activity-groups {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.category-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: visible;
}
.category-activities {
  overflow: hidden;
}
.category-group.progress-red { border-left: 4px solid #ef4444; }
.category-group.progress-yellow { border-left: 4px solid #eab308; }
.category-group.progress-green { border-left: 4px solid #22c55e; }
.progress-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 4px;
}
.progress-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 16px;
  right: 16px;
  margin-bottom: 4px;
  padding: 8px 12px;
  background: var(--color-text);
  color: #fff;
  font-size: 13px;
  font-weight: 400;
  border-radius: 8px;
  z-index: 10;
  line-height: 1.4;
}
.progress-tooltip.visible { display: block; }
.category-title { position: relative; }
.category-title {
  font-size: 16px;
  font-weight: 700;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.category-title::-webkit-details-marker { display: none; }
.category-title::marker { display: none; content: ""; }
.category-icon { font-size: 20px; }
.category-count {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 14px;
}
.category-cal {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.category-repeat-btn {
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 14px;
  line-height: 1;
  border-radius: 50%;
  min-width: 28px;
  min-height: 28px;
}
.category-chevron {
  margin-left: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
  transition: transform 0.2s;
}
.category-chevron::after { content: "▶"; }
details.category-group[open] .category-chevron {
  transform: rotate(90deg);
}
.category-activities {
  padding: 0 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.category-activities .activity-card {
  border: 1px solid var(--color-border);
}

/* Activity Card */
.activity-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.activity-card-compact {
  padding: 8px 14px;
  margin-bottom: 6px;
}
.activity-card-compact .activity-details {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.activity-card-compact .activity-value {
  font-size: 15px;
  font-weight: 600;
}
.activity-notes-compact {
  color: #888;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow);
}
.activity-photo {
  margin-bottom: 10px;
}
.activity-photo img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: 8px;
}
.activity-details {
  margin-bottom: 8px;
}
.activity-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-primary);
}
.activity-notes {
  color: var(--color-text);
  font-size: 14px;
  margin-top: 4px;
}
.activity-time {
  font-size: 12px;
  color: var(--color-text-muted);
}
.activity-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-muted);
}
.empty-state p { margin-bottom: 8px; }

/* Diet Tips */
.diet-tips-section { margin-top: 24px; }
.tips-question-wrapper {
  position: relative;
  margin-bottom: 8px;
}
.tips-question-input {
  width: 100%;
  padding: 10px 44px 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  box-sizing: border-box;
}
.dictation-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.dictation-btn:hover { color: var(--color-text); background: var(--color-hover); }
.dictation-btn.listening { color: #e53e3e; animation: pulse-mic 1.2s ease-in-out infinite; }
@keyframes pulse-mic {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.tips-loading {
  text-align: center;
  color: var(--color-text-muted);
  padding: 16px;
  font-style: italic;
}
.tips-error {
  text-align: center;
  color: var(--color-danger);
  padding: 16px;
}
.tips-content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-text);
}

/* Form */
.activity-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: var(--color-bg);
  transition: border-color 0.15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea.form-input { resize: vertical; }
select.form-input { appearance: auto; }
.form-row {
  display: flex;
  gap: 12px;
}
.form-group-half { flex: 1; }
.form-group-checkbox {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.form-group-checkbox label {
  margin: 0;
  font-weight: 500;
  cursor: pointer;
}
.form-group-checkbox .form-hint {
  width: 100%;
  margin-top: 0;
}
.form-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.voice-input-row {
  margin-bottom: 16px;
}
.btn-voice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  padding: 10px 16px;
  font-size: 15px;
}
.btn-voice svg { flex-shrink: 0; }
.btn-voice.listening {
  color: #e53e3e;
  border-color: #e53e3e;
  animation: pulse-mic 1.2s ease-in-out infinite;
}
.voice-status {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
}
.quick-action-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.quick-action-row {
  display: flex;
  gap: 12px;
}
.btn-quick-action {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-quick-action svg {
  width: 22px;
  height: 22px;
}
.btn-quick-action:active {
  transform: scale(0.97);
}
.btn-quick-mic {
  border-color: #1a1a1a;
  color: #1a1a1a;
}
.btn-quick-mic:hover { background: rgba(0, 0, 0, 0.03); }
.btn-quick-mic.listening {
  color: #e53e3e;
  border-color: #e53e3e;
  background: rgba(229, 62, 62, 0.05);
  animation: pulse-mic 1.2s ease-in-out infinite;
}
.btn-quick-camera {
  border-color: #1a1a1a;
  color: #1a1a1a;
}
.btn-quick-camera:hover { background: rgba(0, 0, 0, 0.03); }
.btn-quick-health {
  border-color: #e53e3e;
  color: #e53e3e;
}
.btn-quick-health:hover { background: rgba(229, 62, 62, 0.05); }
.btn-quick-action.btn-loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn-quick-action.btn-loading svg {
  display: none;
}
.btn-quick-action.btn-loading::before {
  content: "";
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.btn-quick-label {
  font-size: 13px;
  letter-spacing: 0.02em;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.inline-log-estimate {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}
.inline-log-success { background: #fafafa; border: 1px solid #e5e5e5; color: var(--color-text); }
.inline-log-error { background: #f5f5f5; border: 1px solid #e5e5e5; color: var(--color-danger); }
.inline-log-muted { background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-text-muted); }
.estimate-section { margin-bottom: 16px; }
.btn-estimate-preview { font-size: 14px; }
.estimate-result {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
}
.estimate-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: var(--color-text);
}
.estimate-error {
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  color: var(--color-danger);
}
.estimate-muted {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}
.estimate-category {
  font-weight: 600;
  text-transform: capitalize;
}
.estimate-calories {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-primary);
}
.estimate-macros { color: var(--color-text-muted); }
.estimate-notes { font-style: italic; }
.estimate-detail { color: var(--color-text-muted); font-size: 13px; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.form-actions .btn { flex: 1; }
.form-errors {
  background: #f5f5f5;
  border: 1px solid #e5e5e5;
  color: var(--color-danger);
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
}
.form-errors ul { margin-left: 16px; margin-top: 4px; }
.photo-preview {
  margin-top: 8px;
}
.photo-preview img {
  max-width: 200px;
  border-radius: 8px;
}
.form-hint {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}
.unit-combo .form-input {
  width: 100%;
}

/* Calorie Summary */
.calorie-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  min-width: 0;
}
.calorie-card {
  flex: 1;
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.calorie-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
.calorie-number {
  display: block;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}
.calorie-unit {
  font-size: 12px;
  color: var(--color-text-muted);
}
.calorie-in .calorie-number { color: #1a1a1a; }
.calorie-out .calorie-number { color: #1a1a1a; }
.calorie-positive .calorie-number { color: #1a1a1a; }
.calorie-negative .calorie-number { color: #1a1a1a; }
.calorie-breakdown {
  display: block;
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Activity calorie badge */
.activity-calories {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 12px;
}
.activity-calories.cal-in {
  background: #f5f5f5;
  color: #1a1a1a;
}
.activity-calories.cal-out {
  background: #f5f5f5;
  color: #1a1a1a;
}

.activity-macros {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.macro-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
}
.macro-protein { background: #f0f0f0; color: #333; }
.macro-carbs   { background: #f0f0f0; color: #333; }
.macro-fat     { background: #f0f0f0; color: #333; }
.macro-fiber   { background: #f0f0f0; color: #333; }
.macro-sugar   { background: #f0f0f0; color: #333; }

.risk-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-top: 4px;
}
.risk-dots {
  font-size: 16px;
  letter-spacing: 2px;
}
.risk-label {
  font-weight: 600;
}
.risk-reason {
  color: var(--color-text-muted);
}

.bp-analysis-result {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
}
.bp-classification {
  font-size: 14px;
}
.bp-analysis-text {
  color: var(--color-text);
}

/* Metrics / Charts */
.date-range-picker {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 16px;
}
.date-range-field {
  flex: 1;
}
.date-range-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.date-range-field input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
}
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.chart-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--color-text);
}

/* Auth styles */
.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--color-border);
}
.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.auth-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.auth-hint {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.auth-links {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
}
.auth-links p { margin: 6px 0; }
.auth-links a { color: var(--color-primary); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.share-section {
  margin-top: 32px;
}
.btn-share {
  font-size: 15px;
  color: var(--color-text-muted);
}
.flash-alert {
  background: #f5f5f5;
  border-color: #e5e5e5;
  color: var(--color-danger);
}
.nsec-warning {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}
.mono-field {
  font-family: monospace;
  font-size: 12px;
  word-break: break-all;
}
.keypair-display {
  margin-top: 16px;
}
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  max-width: 600px;
  margin: 0 auto;
}
.nav-health-sync {
  position: relative;
}
.btn-health-sync {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: #e53e3e;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.btn-health-label {
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
}
.btn-health-sync:active { opacity: 0.6; }
.btn-health-sync.btn-loading {
  opacity: 0.5;
  pointer-events: none;
}
.btn-health-sync.btn-loading svg { display: none; }
.btn-health-sync.btn-loading::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: #e53e3e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: block;
}
.health-sync-status {
  position: absolute;
  right: 0;
  top: 100%;
  white-space: nowrap;
  font-size: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 4px 8px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.hamburger-btn {
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--color-text);
  border-radius: var(--radius);
}
.hamburger-btn:active { background: var(--color-bg); }
.nav-center {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
}
.nav-version {
  font-size: 11px;
  color: #aaa;
  font-weight: 500;
}

/* Sidebar */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--color-surface);
  z-index: 999;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}
.sidebar.open {
  transform: translateX(0);
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-user {
  font-size: 13px;
  font-family: monospace;
  color: var(--color-text-muted);
}
.sidebar-close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0 4px;
}
.sidebar-links {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.sidebar-link:hover, .sidebar-link:active {
  background: var(--color-bg);
}
.sidebar-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
}
.sidebar-signout {
  margin-top: 8px;
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
  color: var(--color-danger);
}

/* Extension button */
.extension-section {
  margin-bottom: 16px;
  text-align: center;
}
.btn-extension {
  background: #1a1a2e;
  color: #FFDF6F;
  border: 1px solid #333;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 20px;
}
.btn-extension:hover {
  background: #2a2a3e;
}
.btn-extension:disabled {
  opacity: 0.7;
  cursor: wait;
}
.extension-status {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 8px;
}

/* Face ID sign-in */
.faceid-section {
  margin-bottom: 8px;
}
.btn-faceid {
  background: var(--color-bg);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
  font-weight: 600;
  font-size: 16px;
  padding: 14px 20px;
}
.btn-faceid:hover {
  background: var(--color-primary);
  color: #fff;
}
.btn-faceid:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--color-text-muted);
  font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.dropzone:hover, .dropzone-active {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.04);
}
.dropzone-hint {
  color: var(--color-text-muted);
  font-size: 14px;
  margin-bottom: 8px;
}
.dropzone-file-input {
  width: 100%;
}
.dropzone-camera-row {
  margin-top: 8px;
  text-align: center;
}
.btn-camera {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dropzone-camera-input {
  display: none;
}
.dropzone-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.dropzone-thumb {
  position: relative;
  width: 80px;
  height: 80px;
}
.dropzone-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}
.dropzone-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-danger);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Photo Grid (index cards) */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}
.photo-grid img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
}

/* Existing photos in form */
.existing-photos {
  margin-top: 10px;
}
.photo-grid-item {
  position: relative;
}
.photo-grid-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
}

/* Quick Add */
.quick-add-form {
  display: flex;
  gap: 6px;
  align-items: center;
}
.quick-add-input {
  width: 70px;
  padding: 4px 8px;
  font-size: 14px;
}

/* Calorie estimation */
.calorie-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.calorie-input-row .form-input {
  flex: 1;
}
.btn-estimate {
  white-space: nowrap;
  flex-shrink: 0;
}
.calorie-status {
  display: block;
  font-size: 13px;
  color: var(--color-primary);
  margin-top: 4px;
  font-style: italic;
}

/* Profile Sections */
.profile-section {
  border: none;
  padding: 0;
  margin-bottom: 24px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-border);
}

/* Recommendations Card */
.recommendations-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.goal-badge {
  display: inline-block;
  background: var(--color-primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.rec-item {
  text-align: center;
  padding: 10px 6px;
  background: var(--color-bg);
  border-radius: 8px;
}
.rec-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.rec-value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--color-primary);
}
.rec-unit {
  font-size: 11px;
  color: var(--color-text-muted);
}
.rec-progress {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
.rec-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.rec-bar-burn { background: #16a34a; }
.rec-bar-cal { background: #2563eb; }
.rec-bar-water { background: #3b82f6; }
.rec-bar-protein { background: #8b5cf6; }
.rec-bar-carbs { background: #f59e0b; }
.rec-bar-fat { background: #ec4899; }
.rec-actual {
  display: block;
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 3px;
}
.rec-has-tip {
  position: relative;
  cursor: pointer;
}
.rec-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  min-width: 180px;
  max-width: 260px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  margin-bottom: 6px;
}
.rec-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
}
.rec-has-tip:hover .rec-tooltip,
.rec-has-tip:focus-within .rec-tooltip {
  display: block;
}
.rec-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  white-space: nowrap;
}
.rec-tip-row + .rec-tip-row {
  border-top: 1px solid rgba(255,255,255,0.1);
}
.rec-details {
  font-size: 14px;
  color: var(--color-text-muted);
}
.rec-details p {
  margin-bottom: 4px;
}

/* Profile Details */
.profile-details-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.profile-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 14px;
}
.profile-dl dt {
  font-weight: 600;
  color: var(--color-text-muted);
}
.profile-dl dd {
  color: var(--color-text);
}

/* Daily Targets on Index */
.daily-targets {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.target-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.target-row:last-child {
  margin-bottom: 0;
}
.target-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 55px;
}
.target-progress {
  flex: 1;
  height: 8px;
  background: var(--color-bg);
  border-radius: 4px;
  overflow: hidden;
}
.target-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  transition: width 0.3s;
}
/* Stacked exercise bar */
.target-stacked {
  display: flex;
  overflow: hidden;
}
.target-segment {
  height: 100%;
  transition: width 0.3s;
}
.segment-walk { background: #1a1a1a; }
.segment-run { background: #555; }
.segment-weights { background: #888; }
.segment-yoga { background: #bbb; }

.exercise-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  margin-bottom: 6px;
  padding-left: 65px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--color-text-muted);
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-walk { background: #1a1a1a; }
.legend-run { background: #555; }
.legend-weights { background: #888; }
.legend-yoga { background: #bbb; }
.target-bar-water {
  background: #1a1a1a;
}
.target-bar-prayer {
  background: #888;
}
.target-bar-protein { background: #1a1a1a; }
.target-bar-carbs   { background: #666; }
.target-bar-fat     { background: #999; }
.target-numbers {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}
.target-detail {
  font-size: 10px;
  color: var(--color-text-muted);
  padding-left: 65px;
  margin-top: -4px;
  margin-bottom: 4px;
}

/* Previous Day Tags */
.prev-day-tags {
  margin-bottom: 20px;
}
.prev-day-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}
.prev-day-hint {
  font-size: 11px;
  color: var(--color-primary);
  font-style: italic;
  margin-bottom: 8px;
}
details.collapsible-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
details.collapsible-card summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}
details.collapsible-card summary::after {
  content: "\25B6";
  font-size: 10px;
  color: var(--color-text-muted);
  transition: transform 0.2s;
}
details.collapsible-card[open] summary::after {
  transform: rotate(90deg);
}
details.collapsible-card[open] summary {
  margin-bottom: 10px;
}
details.collapsible-card summary::-webkit-details-marker {
  display: none;
}
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag-btn {
  display: inline-block;
  padding: 6px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.tag-btn:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.tag-wrapper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  overflow: hidden;
  background: var(--color-surface);
}
.tag-wrapper .tag-btn {
  border: none;
  border-radius: 20px 0 0 20px;
  padding-right: 8px;
}
.tag-dismiss {
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  background: var(--color-surface);
  border: none;
  border-left: 1px solid var(--color-border);
  color: var(--color-text-muted, #999);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}
.daily-repeat-tags .tag-wrapper {
  border-color: var(--color-primary);
}
.daily-repeat-tags .tag-btn {
  border: none;
  border-radius: 20px;
  padding-right: 12px;
}
.tag-wrapper-with-delete .tag-btn {
  border-radius: 20px 0 0 20px;
  padding-right: 8px;
}
.tag-delete-btn {
  background: none;
  border: none;
  border-left: 1px solid var(--color-border);
  padding: 4px 10px;
  color: var(--color-text-muted, #999);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
}
.tag-delete-btn:hover {
  background: #fee;
  color: #c00;
}
.tag-dismiss:hover {
  background: #fee;
  color: #c00;
}

/* Biometric Lock Overlay */
.biometric-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.biometric-overlay-content {
  text-align: center;
  padding: 24px;
}
.biometric-icon {
  font-size: 64px;
  margin-bottom: 16px;
}
.biometric-overlay-content h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.biometric-overlay-content p {
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

/* Biometric Toggle (Profile) */
.biometric-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.biometric-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 28px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Admin Dashboard */
.admin-container {
  max-width: 900px;
}
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.admin-stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.admin-stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.admin-stat-number {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.2;
}
.admin-stat-detail {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.admin-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.admin-half {
  flex: 1;
  min-width: 0;
}
.admin-breakdown-list {
  margin-top: 12px;
}
.admin-breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
}
.admin-breakdown-row:last-child { border-bottom: none; }
.admin-breakdown-label { color: var(--color-text); }
.admin-breakdown-value { font-weight: 700; color: var(--color-primary); }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 8px 10px;
  border-bottom: 2px solid var(--color-border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-visits-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 640px) {
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-row {
    flex-direction: column;
  }
  .admin-stat-number {
    font-size: 22px;
  }
}
