/* ============================================================
   FamHealth — Base Styles
   Soft Structuralism · Geist geometric sans · Warm paper · Mobile-first
   ============================================================ */

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

:root {
  /* ── Palette (light, default) ── */
  --paper:    #FBF8F2;
  --paper-2:  #FBF8F2;
  --stone:    #EDE7DA;
  --ink:      #1A1A1A;
  --ink-2:    #4A4A4A;
  --ink-3:    #8A8884;
  --moss:     #2F5A3C;
  --moss-2:   #3D7A52;
  --accent:   #2F5A3C;
  --accent-soft: #4A7256;
  --danger:   #B5403A;
  --border:   rgba(26, 26, 26, 0.10);
  --border-s: rgba(26, 26, 26, 0.06);
  --tab-bar-bg:  rgba(250, 248, 244, 0.88);
  --rail-bg:     rgba(242, 239, 232, 0.92);
  --overlay:     rgba(14, 14, 16, 0.48);
  --moss-tint:   rgba(31, 77, 52, 0.08);
  --moss-tint-2: rgba(31, 77, 52, 0.10);
  --accent-tint: rgba(31, 77, 52, 0.08);

  /* ── Elevation ladder (light) ── */
  --surface-1: #FBF8F2;
  --surface-2: #F3EFE6;
  --surface-3: #ECE7DB;
  --surface-4: #FFFFFF;
  --edge-hi:   rgba(255, 255, 255, 0.6);

  /* ── Fonts ── */
  --font:         'Geist', system-ui, -apple-system, sans-serif;
  --font-display: 'Geist', system-ui, sans-serif;
  --font-serif:   'Instrument Serif', Georgia, serif;

  /* ── Motion ── */
  --dur-instant:  100ms;
  --dur-fast:     160ms;
  --dur-normal:   220ms;
  --dur-slow:     300ms;
  --ease-enter:   cubic-bezier(0.22, 1, 0.36, 1);
  --ease-exit:    cubic-bezier(0.32, 0, 0.67, 0);
  --ease-move:    cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring:  linear(0, 0.4 9%, 0.93 24%, 1.06 38%, 1.01 61%, 1);

  /* ── Layout ── */
  --radius:      14px;
  --radius-sm:   10px;
  --radius-lg:   20px;
  --radius-pill: 9999px;
  --tab-h:       64px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-vvh:     100dvh;
  --app-vv-top:  0px;

  /* ── Shadows ── */
  --shadow-card:  0 1px 2px rgba(26, 26, 26, 0.05), 0 2px 8px rgba(26, 26, 26, 0.04);
  --shadow-float: 0 8px 32px rgba(26, 26, 26, 0.10);
  --shadow-inset: inset 0 1px 3px rgba(26, 26, 26, 0.06);
  --shadow-glow:  0 0 0 1px var(--moss-tint), 0 4px 20px rgba(47, 90, 60, 0.12);

  /* ── Ring ── */
  --ring-track: var(--border);
  --ring-fill:  var(--moss);
}

/* ── Palette (dark) ── */
:root[data-theme="dark"] {
  --paper:    #0E1117;
  --paper-2:  #131A1A;
  --stone:    #1C2320;
  --ink:      #ECE8DF;
  --ink-2:    #B8B4A8;
  --ink-3:    #7A7670;
  --moss:     #5FA378;
  --moss-2:   #75BA8E;
  --accent:   #5FA378;
  --accent-soft: #4E8466;
  --danger:   #E36659;
  --border:   rgba(236, 232, 223, 0.10);
  --border-s: rgba(236, 232, 223, 0.06);
  --tab-bar-bg:  rgba(14, 17, 23, 0.92);
  --rail-bg:     rgba(14, 17, 23, 0.94);
  --overlay:     rgba(0, 0, 0, 0.65);
  --moss-tint:   rgba(95, 163, 120, 0.10);
  --moss-tint-2: rgba(95, 163, 120, 0.16);
  --accent-tint: rgba(95, 163, 120, 0.10);

  /* ── Elevation ladder (dark) ── */
  --surface-1: #0E1117;
  --surface-2: #161B22;
  --surface-3: #1E242D;
  --surface-4: #232A34;
  --edge-hi:   rgba(255, 255, 255, 0.05);

  /* ── Shadows (dark — deep blacks) ── */
  --shadow-card:  0 1px 2px rgba(0, 0, 0, 0.40), 0 2px 10px rgba(0, 0, 0, 0.30);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.55);
  --shadow-inset: inset 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-glow:  0 0 0 1px var(--moss-tint-2), 0 4px 24px rgba(95, 163, 120, 0.18);

  /* ── Ring (dark) ── */
  --ring-track: rgba(236, 232, 223, 0.10);
  --ring-fill:  var(--moss);
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Reduced transparency ── */
@media (prefers-reduced-transparency: reduce) {
  #tab-bar,
  .glass {
    background: var(--paper);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ── Forced colors ── */
@media (forced-colors: active) {
  .tab-btn.active { border-top: 2px solid Highlight; }
  .btn:focus-visible,
  .tab-btn:focus-visible,
  .meal-card:focus-visible,
  .set-btn:focus-visible { outline: 2px solid Highlight; }
}

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-width: 320px;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   Layout
   ============================================================ */

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
}

/* Person selector bar */
#person-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.person-pills {
  display: flex;
  gap: 6px;
}

.person-btn {
  background: var(--stone);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: var(--font);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
}

.person-btn.active {
  background: var(--moss);
  border-color: var(--moss);
  color: #FBF8F2;
}

.person-btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.sync-config-btn {
  background: transparent;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 6px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
}

.sync-config-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sync-config-btn:hover {
  background: var(--stone);
  color: var(--ink);
}
.sync-config-btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

/* Main content area — scrollable, sits above tab bar */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tab-h) + max(var(--safe-bottom), 12px) + 8px);
}

/* ============================================================
   Bottom Tab Bar
   ============================================================ */

#tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-h) + max(var(--safe-bottom), 12px));
  padding-bottom: max(var(--safe-bottom), 12px);
  background: var(--tab-bar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 10;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-enter),
              transform var(--dur-fast) var(--ease-enter);
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.tab-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-enter);
}

.tab-btn.active {
  color: var(--moss);
}

.tab-btn.active svg {
  transform: translateY(-1px);
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: -2px;
}

/* ============================================================
   Tab Panels
   ============================================================ */

.tab-panel {
  display: none;
  padding: 28px 16px 24px;
  min-height: 100%;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--dur-fast) var(--ease-enter),
              transform var(--dur-fast) var(--ease-enter);
}

.tab-panel.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.tab-panel.entering {
  display: block;
}

/* ============================================================
   Typography
   ============================================================ */

h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-wrap: balance;
}

h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

h3 {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--ink);
}

p {
  text-wrap: pretty;
}

/* Eyebrow label — geometric micro-caps, Geist */
.label,
.eyebrow {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Editorial numeral — Instrument Serif, large, faint moss */
.editorial-number {
  font-family: var(--font-serif);
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 400;
  line-height: 1;
  color: var(--moss);
  opacity: 0.18;
  user-select: none;
  pointer-events: none;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--ink-2);
  font-size: 14px;
}

/* Meal section header — serif title in accent + tinted rule */
.meal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.meal-header-title {
  font-family: var(--font-serif);
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--accent);
  line-height: 1.1;
  white-space: nowrap;
}
.meal-header-rule {
  flex: 1;
  height: 1px;
  background: rgba(16, 185, 129, 0.2);
}

/* ============================================================
   Section rule
   ============================================================ */

.rule {
  height: 1px;
  background: var(--border);
  margin-block: 32px;
}

/* Keep .divider as alias */
.divider {
  height: 1px;
  background: var(--border);
  margin-block: 28px;
}

/* ============================================================
   Cards — structural surfaces only
   ============================================================ */

.card {
  background: var(--stone);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border-s);
  box-shadow: var(--shadow-inset);
}

.card + .card {
  margin-top: 12px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-enter),
              transform var(--dur-fast) var(--ease-enter),
              opacity var(--dur-fast) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--moss);
  color: var(--paper);
  box-shadow: 0 1px 2px rgba(14,14,16,0.12), var(--shadow-inset);
}

.btn-primary:hover {
  background: var(--moss-2);
}

.btn-primary.btn-full {
  min-height: 48px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.btn-secondary {
  background: var(--stone);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary.btn-full {
  min-height: 48px;
}

.btn-ghost {
  background: transparent;
  color: var(--moss);
  border: 1px solid var(--border);
}

.btn-full {
  width: 100%;
}

/* ============================================================
   Section headers
   ============================================================ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ============================================================
   Badge / Pill
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-low  { background: rgba(31,77,52,0.10); color: var(--moss); }
.badge-med  { background: rgba(201,123,74,0.12); color: #9B5C2A; }

/* ============================================================
   Scrollbar (desktop)
   ============================================================ */

#content::-webkit-scrollbar { width: 4px; }
#content::-webkit-scrollbar-track { background: transparent; }
#content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================================
   Empty state
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--ink-2);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--border);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================================
   Progress bar + ring
   ============================================================ */

.progress-bar-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width var(--dur-slow) var(--ease-move);
  min-width: 0;
}

/* ============================================================
   Hoje — header
   ============================================================ */

.hoje-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.hoje-header h1 {
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 3px;
}

.progress-ring-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.01em;
}

/* ============================================================
   Workout card
   ============================================================ */

.workout-card {
  padding: 0 0 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.workout-card-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--moss);
  margin-bottom: 6px;
}

.workout-card-name {
  font-family: var(--font-display);
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 4px;
}

.workout-card-meta {
  font-size: 13px;
  color: var(--ink-2);
}

.workout-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 16px;
  background: rgba(31, 77, 52, 0.10);
  border-radius: var(--radius-sm);
  color: var(--moss);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.training-advice {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-2);
}

.training-advice.is-dynamic {
  color: var(--moss);
}

.workout-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 16px;
}

.workout-action-row .btn {
  min-height: 42px;
  padding-inline: 14px;
}

.run-log-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 0 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.run-log-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.run-log-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.run-log-field span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.run-log-field input[readonly] {
  color: var(--moss);
  font-weight: 700;
  background: rgba(47, 90, 60, 0.08);
}

.run-duration-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.run-duration-row label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-inline-end: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.run-duration-row input.notes-input {
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
}

.run-duration-row small {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: lowercase;
}

.run-log-field.is-invalid input {
  border-color: var(--danger);
}

.run-duration-row label:focus-within {
  border-color: var(--moss);
}

/* ============================================================
   Meal cards
   ============================================================ */

.meal-section {
  margin-bottom: 24px;
  padding: 0;
}

.meal-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.meal-card {
  padding: 13px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-block-end: 1px solid var(--border-s);
  transition: opacity var(--dur-fast) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.meal-card:last-of-type {
  border-block-end: none;
  padding-bottom: 10px;
}

.meal-card:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
  border-radius: 4px;
}

.meal-card.done {
  opacity: 0.72;
}

.meal-check {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter),
              transform var(--dur-fast) var(--ease-enter);
  background: var(--paper);
}

.meal-card.done .meal-check {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--paper);
  transform: scale(1.08);
}

.meal-info {
  flex: 1;
  min-width: 0;
}

.meal-option-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--moss);
  background: rgba(31, 77, 52, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.meal-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.meal-card.done .meal-name {
  text-decoration: line-through;
  color: var(--ink-2);
}

.meal-kcal {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Modal (slide-up sheet)
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 30;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-enter);
  pointer-events: none;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--paper);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-move);
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 48px -8px rgba(14,14,16,0.12);
}

.modal-backdrop.open .modal {
  transform: translateY(0);
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#perfil-edit-modal {
  inset: var(--app-vv-top) 0 auto 0;
  height: var(--app-vvh);
}

#perfil-edit-modal .modal {
  max-height: min(92dvh, calc(var(--app-vvh) - 8px));
}

#perfil-edit-modal.keyboard-open .modal {
  max-height: calc(var(--app-vvh) - 8px);
}

#perfil-edit-modal .modal-body {
  scroll-padding-block: 24px 112px;
}

#perfil-edit-modal.keyboard-open .modal-body {
  padding-bottom: 96px;
}

#perfil-edit-modal .modal-footer {
  background: var(--paper);
  padding-bottom: calc(12px + max(var(--safe-bottom), 0px));
}

/* ============================================================
   Exercise items
   ============================================================ */

.exercise-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

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

.exercise-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.exercise-header-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.exercise-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.exercise-meta {
  font-size: 13px;
  color: var(--moss);
  flex-shrink: 0;
  font-weight: 600;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}

.demo-link {
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: none;
}
.demo-link:hover { color: var(--moss); }

/* ── Exercise animation ── */
/* ── Animation style toggle pills ── */
.anim-style-toggle-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 16px;
}

.anim-style-pills {
  display: flex;
  gap: 4px;
  background: var(--stone);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-s);
}

.anim-style-btn {
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: var(--font);
  transition: background-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
}

.anim-style-btn.active {
  background: var(--moss);
  color: var(--paper);
}

.anim-style-btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 1px;
}

.ex-anim-wrap {
  margin: 10px 0 6px;
  background: var(--stone);
  border-radius: 6px;
  overflow: hidden;
  padding: 6px 4px 4px;
}

.ex-anim {
  display: block;
  width: 100%;
  max-height: 130px;
}

/* GIF exercise animation with seamless blend */
.ex-gif-wrap {
  margin: 10px 0 6px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--stone);
  border: 1px solid var(--border-s);
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-enter);
}

.ex-gif {
  display: block;
  width: auto;
  max-width: 92%;
  height: clamp(180px, 44vw, 240px);
  object-fit: contain;
  mix-blend-mode: multiply;
}

/* Dark mode compatibility for GIFs */
:root[data-theme="dark"] .ex-gif-wrap {
  background: #141914;
}

:root[data-theme="dark"] .ex-gif {
  filter: invert(1) hue-rotate(180deg) contrast(1.15);
  mix-blend-mode: screen;
}

/* ── Technique collapsible ── */
.technique-details {
  margin: 8px 0 0;
}

.technique-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}

.technique-summary::-webkit-details-marker { display: none; }

.technique-summary::before {
  content: '▶';
  font-size: 8px;
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease-enter);
}

details[open] .technique-summary::before {
  transform: rotate(90deg);
}

.technique-text {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  padding: 8px 0 4px 14px;
  border-left: 2px solid var(--border);
  margin-top: 4px;
}

/* ── Set buttons ── */
.set-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.set-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter),
              transform var(--dur-instant) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.set-btn.done {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--paper);
}

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

.set-btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

/* ============================================================
   Rest timer
   ============================================================ */

.timer-section {
  padding: 20px 0 0;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}

.timer-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 12px;
}

.timer-display {
  font-family: var(--font-display);
  font-size: clamp(52px, 14vw, 80px);
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  line-height: 1;
  margin-bottom: 16px;
  letter-spacing: -0.04em;
}

.timer-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

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

.preset-btn {
  flex: 1;
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter),
              background-color var(--dur-fast) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
}

.preset-btn.active {
  border-color: var(--moss);
  color: var(--moss);
  background: rgba(31, 77, 52, 0.08);
}

.preset-btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

/* ============================================================
   Notes textarea
   ============================================================ */

.notes-input {
  width: 100%;
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 80px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-enter);
}

.notes-input:focus {
  border-color: var(--moss);
}

.notes-input[readonly]:focus {
  border-color: var(--border);
  cursor: default;
}

.notes-input::placeholder { color: var(--ink-2); opacity: 0.6; }

/* ============================================================
   Day tab nav (Comida) — text-only with interpuncts
   ============================================================ */

.day-tabs-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.day-tabs-row::-webkit-scrollbar { display: none; }

.day-tab-btn {
  min-height: 44px;
  padding: 0 10px;
  border-radius: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  user-select: none;
}

.day-tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--moss);
  font-weight: 600;
}

.day-tab-today-pill {
  display: inline-block;
  background: var(--moss);
  color: #0A0A0A;
  border-radius: 20px;
  padding: 2px 8px;
  font-weight: 700;
  line-height: 1.4;
}

.day-tab-btn.active .day-tab-today-pill {
  background: var(--moss);
  color: #0A0A0A;
}

.day-tab-btn:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

/* ============================================================
   Meal cards (Comida)
   ============================================================ */

.meal-detail-card {
  border-block-end: 1px solid var(--border);
  margin-bottom: 0;
  overflow: hidden;
}

.meal-detail-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  color: var(--ink);
}

/* ============================================================
   Recipes
   ============================================================ */

.recipes-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.recipe-count {
  min-width: 58px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--moss);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  background: rgba(31, 77, 52, 0.06);
  font-variant-numeric: tabular-nums;
}

.recipe-search-wrap {
  position: relative;
  margin-bottom: 12px;
}

.recipe-search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  stroke: var(--ink-2);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.recipe-search {
  width: 100%;
  min-height: 44px;
  padding: 0 14px 0 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-enter);
}

.recipe-search:focus {
  border-color: var(--moss);
}


.recipe-filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px 12px;
  padding: 0 16px 4px;
  scrollbar-width: none;
}

.recipe-filter-row::-webkit-scrollbar { display: none; }

.recipe-filter-sep {
  height: 1px;
  background: var(--border);
  margin: 0 0 12px;
}

.recipe-filter-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 0 4px 0 2px;
}

.recipe-filter-divider {
  flex: 0 0 1px;
  align-self: stretch;
  background: var(--border);
  margin: 8px 8px;
}

.recipe-chip {
  flex: 0 0 auto;
  min-height: 36px;
  max-width: 210px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-enter),
              background var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter);
}

.recipe-chip.active {
  color: var(--moss);
  background: rgba(16, 185, 129, 0.12);
  border-color: var(--moss);
}

.recipe-chip:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.recipe-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 16px;
}

.recipe-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.recipe-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--moss);
}

.recipe-list {
  display: grid;
  gap: 1px;
  background: var(--border-s);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.recipe-card {
  overflow: hidden;
  background: var(--paper);
  transition: box-shadow var(--dur-fast) var(--ease-enter);
  container-type: inline-size;
  container-name: recipe;
}

@media (hover: hover) and (pointer: fine) {
  .recipe-card:hover {
    box-shadow: 0 2px 16px rgba(14,14,16,0.08);
    position: relative;
    z-index: 1;
  }
}

.recipe-summary {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 16px;
  gap: 16px;
  align-items: center;
  min-height: 174px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}

.recipe-category-tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--stone);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.recipe-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.recipe-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.recipe-meta-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.75;
}

.recipe-macro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.macro-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 4px;
  border-radius: 8px;
  background: var(--stone);
  text-align: center;
  line-height: 1.1;
}

.macro-chip .macro-num {
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.macro-chip .macro-lbl {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

.macro-chip.macro-kcal { background: rgba(239, 165, 76, 0.14); }
.macro-chip.macro-kcal .macro-num { color: #B96A1A; }
.macro-chip.macro-p { background: rgba(16, 185, 129, 0.14); }
.macro-chip.macro-p .macro-num { color: #066D52; }
.macro-chip.macro-c { background: rgba(96, 165, 250, 0.16); }
.macro-chip.macro-c .macro-num { color: #1D4FAA; }
.macro-chip.macro-f { background: rgba(168, 85, 247, 0.14); }
.macro-chip.macro-f .macro-num { color: #6B21A8; }


.recipe-summary::-webkit-details-marker {
  display: none;
}

.recipe-img {
  width: 150px;
  height: 150px;
  object-fit: cover;
  object-position: center;
  border-radius: var(--radius-sm);
  background: var(--stone);
  cursor: zoom-in;
  box-shadow: var(--shadow-card);
}

.recipe-summary-main {
  min-width: 0;
}

.recipe-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.recipe-source {
  max-width: 110px;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--stone);
  color: var(--ink-2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recipe-title {
  margin-bottom: 3px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
  text-wrap: pretty;
}

.recipe-meta,
.recipe-macros {
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.35;
}

.recipe-macros {
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.recipe-card[open] .detail-chevron {
  transform: rotate(90deg);
}

.recipe-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}

.recipe-note {
  margin: 12px 0;
  padding: 6px 0 6px 14px;
  border: none;
  border-inline-start: 2px solid var(--moss);
  background: transparent;
}

.recipe-note p {
  color: var(--moss);
  font-size: 12px;
  line-height: 1.45;
}

.recipe-note-title {
  color: var(--moss) !important;
  font-size: 11px !important;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.recipe-note p + p {
  margin-top: 6px;
}

.recipe-subtitle {
  margin: 14px 0 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.recipe-list-clean,
.recipe-steps {
  padding-left: 18px;
  color: var(--ink-2);
  font-size: 13px;
}

.recipe-list-clean li,
.recipe-steps li {
  padding: 3px 0;
}

.recipe-steps {
  padding-left: 20px;
}

.recipe-step-lines {
  padding-left: 0;
  list-style: none;
}

/* ── Container queries: card adapts to own width (must be after base rules) ── */
@container recipe (max-width: 460px) {
  .recipe-summary {
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: 0;
    padding: 10px;
  }
  .recipe-summary .detail-chevron { display: none; }
  .recipe-img {
    width: 100%;
    height: 180px;
    border-radius: var(--radius-sm);
  }
  .recipe-macro-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }
  .recipe-category-tag { max-width: 100%; }
}

@container recipe (min-width: 461px) and (max-width: 620px) {
  .recipe-summary {
    grid-template-columns: 120px minmax(0, 1fr) 14px;
    gap: 12px;
    min-height: 140px;
    padding: 10px;
  }
  .recipe-img { width: 120px; height: 120px; }
  .recipe-macro-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }
  .macro-chip .macro-num { font-size: 12px; }
  .macro-chip .macro-lbl { font-size: 8px; }
}

/* ── Meal card action buttons ─────────────────────────────── */
.meal-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.meal-swap-btn,
.meal-recipe-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--stone);
  color: var(--ink-2);
  border: none;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.meal-swap-btn:hover,
.meal-swap-btn:focus-visible {
  background: var(--accent);
  color: #fff;
  outline: none;
}

.meal-recipe-btn:hover,
.meal-recipe-btn:focus-visible {
  background: var(--moss-tint-2);
  color: var(--accent);
  outline: none;
}

/* ── Meal picker modal ────────────────────────────────────── */
.modal-close-btn {
  background: none;
  border: none;
  color: var(--ink-2);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.meal-picker-search {
  flex-shrink: 0;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
  background: var(--paper);
}
.meal-picker-search .recipe-search-wrap {
  margin-bottom: 12px;
}
.meal-picker-empty {
  padding: 28px 12px;
  color: var(--ink-2);
  font-size: 14px;
  text-align: center;
}
.meal-pick-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 8px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.meal-pick-row:hover,
.meal-pick-row:focus-visible {
  background: var(--stone);
  outline: none;
}
.meal-pick-row.current {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.meal-pick-img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  background: var(--stone);
}
.meal-pick-info {
  flex: 1;
  min-width: 0;
}
.meal-pick-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meal-pick-meta {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 2px;
}
.meal-pick-check {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
}

/* Recipe image modal */
.recipe-image-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(18px, var(--safe-top)) 18px max(18px, var(--safe-bottom));
  background: rgba(26, 26, 26, 0.85);
  z-index: 40;
}

.recipe-image-modal.open {
  display: flex;
}

.recipe-image-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(920px, 96vw);
  max-height: 86dvh;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--stone);
  box-shadow: 0 24px 80px rgba(26, 26, 26, 0.35);
}

.recipe-image-frame.ready {
  width: var(--recipe-image-frame-width);
  height: var(--recipe-image-frame-height);
}

.recipe-image-frame img {
  display: block;
  max-width: min(920px, 96vw);
  max-height: 86dvh;
  object-fit: contain;
  border-radius: inherit;
  background: transparent;
}

.recipe-image-frame.ready img {
  position: absolute;
  left: var(--recipe-image-offset-x);
  top: var(--recipe-image-offset-y);
  width: var(--recipe-image-display-width);
  height: var(--recipe-image-display-height);
  max-width: none;
  max-height: none;
  object-fit: fill;
  border-radius: 0;
}

.recipe-image-frame p {
  display: none;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--stone);
  color: var(--ink);
  font-size: 14px;
}

.recipe-image-close {
  position: fixed;
  top: calc(var(--safe-top) + 14px);
  right: 14px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   Recipe request modal
   ============================================================ */

.recipe-request-btn {
  flex-shrink: 0;
  align-self: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 14px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: opacity 0.15s;
}
.recipe-request-btn:active { opacity: 0.75; }

.rr-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rr-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.rr-required { color: var(--accent); }

.rr-input,
.rr-textarea {
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.rr-input:focus,
.rr-textarea:focus { border-color: var(--accent); }
.rr-textarea { resize: vertical; }

.rr-file-label { position: relative; cursor: pointer; }
.rr-file-btn {
  display: inline-block;
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  color: var(--ink);
}
.rr-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  cursor: pointer;
  z-index: 1;
}
.rr-file-name {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
}

.rr-status {
  font-size: 13px;
  color: #E05252;
  min-height: 18px;
  margin: 0;
}

.rr-submit {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  padding: 13px;
  cursor: pointer;
  width: 100%;
  letter-spacing: 0.01em;
  font-family: inherit;
  transition: opacity 0.15s;
}
.rr-submit:disabled { opacity: 0.5; cursor: not-allowed; }
.rr-submit:not(:disabled):active { opacity: 0.8; }
.rr-submit-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  margin-top: 12px;
}

.rr-success {
  text-align: center;
  padding: 32px 16px;
}
.rr-success-msg {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}
.rr-success-sub {
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 24px;
}

/* ============================================================
   Admin — recipe request cards (perfil tab, henri only)
   ============================================================ */

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

.admin-request-card {
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: opacity 0.3s;
}

.admin-request-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--border);
}

.admin-request-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.admin-request-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.admin-request-meta {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.admin-request-desc {
  font-size: 13px;
  color: var(--ink-2);
  white-space: pre-wrap;
}

.admin-request-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.admin-request-actions {
  display: flex;
  gap: 8px;
}

/* ============================================================
   Recipe detail modal (comida tab)
   ============================================================ */

.recipe-detail-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--stone);
}

.recipe-detail-content {
  padding: 16px 20px 24px;
}

.recipe-detail-macros {
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.recipe-detail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 16px;
}

.recipe-meta-dot {
  color: var(--ink-3);
  opacity: 0.5;
}

.recipe-section {
  margin-top: 20px;
}

.recipe-section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.recipe-ingredients {
  list-style: none;
  padding: 0;
}

.recipe-ingredients li {
  padding: 4px 0;
  font-size: 14px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--border-s);
}

.recipe-ingredients li::before {
  content: "• ";
  color: var(--accent);
}

.recipe-steps {
  list-style: none;
  padding: 0;
  counter-reset: steps;
}

.recipe-steps li {
  counter-increment: steps;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--border-s);
  line-height: 1.5;
}

.recipe-steps li::before {
  content: counter(steps);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--moss-tint);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}


/* ============================================================
   Stats grid
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-s);
}

.stat-label {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(22px, 5vw, 28px);
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

/* ============================================================
   Workout history rows
   ============================================================ */

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-block-end: 1px solid var(--border);
}

.history-row:last-child { border-block-end: none; }

/* ============================================================
   Responsive — Tablet portrait  (≥ 768 px)
   ============================================================ */

@media (min-width: 768px) {
  html, body {
    font-size: 17px;
  }

  .tab-panel {
    padding: 32px 28px 28px;
  }

  .tab-btn {
    min-height: 56px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .recipe-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ============================================================
   Responsive — max 420px
   ============================================================ */

@media (max-width: 420px) {
  /* recipe card layout handled by container queries above */
}

/* ============================================================
   Responsive — Tablet landscape / Fridge  (≥ 1024 px)
   ============================================================ */

@media (min-width: 1024px) {
  :root {
    --rail-w: 100px;
  }

  html, body {
    font-size: 18px;
  }

  /* ── Side rail ── */
  #tab-bar {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: var(--rail-w);
    height: 100dvh;
    border-top: none;
    border-right: 1px solid var(--border);
    background: var(--rail-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    padding: 20px 0;
  }

  .tab-btn {
    flex: none;
    height: 76px;
    min-height: 76px;
    padding: 0 8px;
    margin: 0 8px;
    font-size: 11px;
    border-radius: var(--radius-sm);
    border-bottom: none;
    transition: color var(--dur-fast) var(--ease-enter),
                background-color var(--dur-fast) var(--ease-enter);
  }

  .tab-btn.active {
    color: var(--moss);
    background: rgba(31, 77, 52, 0.08);
  }

  .tab-btn svg {
    width: 28px;
    height: 28px;
  }

  /* ── Content clears the side rail ── */
  #content {
    padding-left: var(--rail-w);
    padding-bottom: 40px;
  }

  /* ── Person bar also clears the side rail ── */
  #person-bar {
    padding-left: calc(var(--rail-w) + 16px);
  }

  .tab-panel {
    max-width: 1280px;
    padding: 36px 44px 36px;
  }

  /* ── Hoje: meal sections side-by-side ── */
  .hoje-meals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 24px;
  }
  .hoje-meals-grid .meal-section { margin-bottom: 0; }

  /* ── Receitas: 3 columns ── */
  .recipe-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* ── Recipe expanded body: larger text for arm's-length reading ── */
  .recipe-detail-body li,
  .recipe-detail-body p,
  .meal-detail-body li {
    font-size: 1.05rem;
  }

  /* ── Workout modals → centered dialog ── */
  .modal-backdrop {
    align-items: center;
    justify-content: center;
  }

  .modal {
    border-radius: var(--radius-lg);
    max-width: 660px;
    width: 90%;
    max-height: 85dvh;
    transform: scale(0.96);
    transition: transform var(--dur-normal) var(--ease-move);
  }

  .modal-backdrop.open .modal {
    transform: scale(1);
  }

  .modal-handle {
    display: none;
  }

  #perfil-edit-modal {
    inset: 0;
    height: 100dvh;
  }

  #perfil-edit-modal .modal {
    max-height: 85dvh;
  }
}

/* ============================================================
   Responsive — Wide screens  (≥ 1400 px)
   ============================================================ */

@media (min-width: 1400px) {
  .recipe-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}


/* ============================================================
   Eyebrow pill — inline tag variant
   ============================================================ */

.eyebrow-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: rgba(14,14,16,0.06);
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}


/* ============================================================
   Lista tab — shopping list
   ============================================================ */

.lista-wrap { padding: 20px 16px 80px; max-width: 720px; margin: 0 auto; }
.lista-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 20px;
}
.lista-header-text { min-width: 0; }
.lista-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--text, var(--ink)); }

/* Segmented supermarket toggle — neutral, lives in header corner */
.lista-sm-toggle {
  display: flex; gap: 2px; flex-shrink: 0; align-self: center;
  background: var(--stone); border-radius: var(--radius-pill);
  padding: 3px;
}
.sm-pill {
  padding: 6px 12px;
  background: transparent; border: none;
  border-radius: var(--radius-pill); font-family: var(--font);
  font-size: 12px; font-weight: 500; color: var(--ink-3);
  cursor: pointer; transition: all var(--dur-fast) var(--ease-move);
  white-space: nowrap;
}
.sm-pill.active { background: var(--paper-2); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.sm-pill:hover:not(.active) { color: var(--ink-2); }

/* Primary generate button — full width, only green element */
.lista-generate-btn { width: 100%; margin-bottom: 10px; }

/* Secondary actions — small ghost row, right-aligned */
.lista-secondary-actions {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 16px;
}
.lista-sec-btn {
  font-size: 12px; padding: 6px 12px; height: auto; min-height: 0;
}
.lista-sec-danger { color: var(--danger) !important; }
.lista-sec-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent) !important; }

.lista-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.lista-actions .btn { flex: 1; }
.lista-export-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.lista-export-actions .btn { flex: 1; font-size: 0.85rem; }

.lista-search { position: relative; margin-bottom: 16px; }
.lista-search input {
  width: 100%; min-height: 44px; padding: 0 14px;
  background: var(--paper-2); border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--font);
  font-size: 14px; color: var(--ink);
}
.lista-search input:focus { outline: none; border-color: var(--moss); }
.lista-search-results {
  display: flex; flex-direction: column; gap: 4px; margin-top: 8px;
  max-height: 320px; overflow-y: auto;
}
.lista-search-row {
  display: flex; align-items: center; gap: 12px; padding: 8px;
  background: var(--paper-2); border: 1px solid var(--border-s);
  border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  font-family: var(--font);
}
.lista-search-row:hover { background: var(--stone); }
.lista-search-row img, .lista-search-noimg {
  width: 44px; height: 44px; object-fit: contain;
  background: var(--paper); border-radius: var(--radius-sm); flex-shrink: 0;
}
.lista-search-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.lista-search-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.lista-search-empty { padding: 12px; color: var(--ink-3); font-size: 13px; }

.lista-status { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; min-height: 16px; }

.lista-items { display: flex; flex-direction: column; gap: 8px; }
.lista-item {
  display: grid;
  grid-template-columns: 32px 56px 1fr auto auto 28px;
  grid-template-areas: "check image info qty line remove";
  align-items: center; gap: 10px; padding: 10px;
  background: var(--paper-2); border: 1px solid var(--border-s);
  border-radius: var(--radius);
  transition: opacity var(--dur-fast);
}
.lista-item.checked { opacity: 0.5; }
.lista-item.checked .lista-item-name { text-decoration: line-through; }

.lista-check { grid-area: check; position: relative; display: inline-flex; cursor: pointer; }
.lista-check input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.lista-check-box {
  width: 22px; height: 22px; border: 2px solid var(--border);
  border-radius: 6px; display: inline-block; background: var(--paper);
  transition: all var(--dur-fast);
}
.lista-check input:checked + .lista-check-box {
  background: var(--moss); border-color: var(--moss);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='5 12 10 17 19 7'/%3E%3C/svg%3E");
  background-position: center; background-repeat: no-repeat; background-size: 14px;
}

.lista-item-img { grid-area: image; width: 56px; height: 56px; }
.lista-item-img img, .lista-item-noimg {
  width: 100%; height: 100%; object-fit: contain;
  background: var(--paper); border-radius: var(--radius-sm);
}
.lista-item-info { grid-area: info; min-width: 0; }
.lista-item-name {
  font-size: 13px; font-weight: 500; color: var(--ink);
  line-height: 1.3; overflow-wrap: anywhere;
}
.lista-item-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.lista-item-qty {
  grid-area: qty;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--border-s);
  border-radius: var(--radius-pill); padding: 2px;
}
.lista-item-qty button {
  width: 24px; height: 24px; border: none; background: transparent;
  cursor: pointer; font-size: 16px; color: var(--ink-2); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.lista-item-qty button:hover { background: var(--stone); }
.lista-item-qty span { min-width: 18px; text-align: center; font-size: 13px; font-weight: 500; }

.lista-item-line { grid-area: line; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; }

.lista-item-remove {
  grid-area: remove;
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--ink-3); font-size: 18px; cursor: pointer; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}
.lista-item-remove:hover { background: var(--stone); color: var(--danger); }

.lista-total {
  position: sticky; bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px);
  margin-top: 20px; padding: 14px 18px;
  background: var(--moss); color: var(--paper);
  border-radius: var(--radius);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px;
}
.lista-total strong { font-size: 18px; }

.empty-state.small { padding: 24px 16px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* Phone layout keeps product text wide and moves controls below it. */
@media (max-width: 560px) {
  .lista-wrap { padding-inline: 14px; }

  .lista-secondary-actions { justify-content: stretch; }
  .lista-sec-btn { flex: 1 1 calc(50% - 6px); min-height: 44px; }

  .lista-item {
    grid-template-columns: 28px 64px minmax(0, 1fr) 28px;
    grid-template-areas:
      "check image info remove"
      ". image qty line";
    align-items: center;
    column-gap: 10px;
    row-gap: 8px;
    padding: 12px;
  }
  .lista-item-img { width: 64px; height: 64px; }
  .lista-item-name { font-size: 14px; overflow-wrap: break-word; }
  .lista-item-meta { font-size: 12px; }
  .lista-item-qty { justify-self: start; }
  .lista-item-line { justify-self: end; }
  .lista-item-remove { align-self: start; }
}

@media (max-width: 360px) {
  .lista-item {
    grid-template-columns: 26px 56px minmax(0, 1fr) 26px;
    column-gap: 8px;
  }
  .lista-item-img { width: 56px; height: 56px; }
  .lista-item-qty { gap: 2px; }
  .lista-item-qty button { width: 22px; height: 22px; }
  .lista-item-line { font-size: 12px; }
}

/* Catálogo PT store sub-filter chips */
.lista-store-chips {
  display: flex; gap: 6px; margin-bottom: 16px;
  overflow-x: auto; padding-bottom: 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.lista-store-chips::-webkit-scrollbar { display: none; }
.store-chip {
  flex-shrink: 0; padding: 6px 12px;
  background: var(--paper-2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); font-family: var(--font);
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
  transition: all var(--dur-fast) var(--ease-move);
}
.store-chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.store-chip:hover:not(.active) { background: var(--stone); }

/* Lista — clickable image button (reset button styling) */
.lista-item-img {
  border: none; padding: 0; background: transparent; cursor: zoom-in;
}
.lista-search-zoom {
  border: none; padding: 0; background: transparent; cursor: zoom-in;
  flex-shrink: 0;
}
.lista-search-add {
  border: none; padding: 0; background: transparent; cursor: pointer;
  flex: 1; min-width: 0; text-align: left; font-family: var(--font);
  color: inherit;
}

/* Lightbox overlay */
.lista-lightbox {
  position: fixed; inset: 0; background: rgba(20, 20, 20, 0.86);
  display: none; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.lista-lightbox.open { display: flex; animation: lbFade var(--dur-normal) var(--ease-enter); }
@keyframes lbFade { from { opacity: 0; } to { opacity: 1; } }

.lista-lightbox-inner {
  position: relative; max-width: 480px; width: 100%; max-height: 90vh;
  background: var(--paper); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  animation: lbScale var(--dur-normal) var(--ease-enter);
}
@keyframes lbScale { from { transform: scale(0.96); } to { transform: scale(1); } }

.lista-lightbox img {
  width: 100%; height: auto; max-height: 65vh; object-fit: contain;
  background: #fff; display: block;
}
.lista-lightbox-info { padding: 16px 20px 20px; }
.lista-lightbox-name {
  font-size: 15px; font-weight: 600; color: var(--ink);
  line-height: 1.4; margin-bottom: 6px;
}
.lista-lightbox-meta { font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
.lista-lightbox-link {
  display: inline-block; color: var(--moss); font-size: 13px;
  font-weight: 500; text-decoration: none;
}
.lista-lightbox-link:hover { text-decoration: underline; }

.lista-lightbox-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.5); color: white;
  font-size: 22px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.lista-lightbox-close:hover { background: rgba(0,0,0,0.75); }

.lista-assistant-inner {
  padding: 48px 24px 28px; overflow-y: auto; gap: 0;
}
.lista-assistant-title {
  font-size: 18px; font-weight: 700; color: var(--ink);
  margin: 0 0 8px;
}
.lista-assistant-sub {
  font-size: 13px; color: var(--ink-2); margin: 0 0 20px; line-height: 1.5;
}
.lista-assistant-platform {
  background: var(--surface-1); border-radius: 10px;
  padding: 16px 18px 14px; margin-bottom: 14px;
}
.lista-assistant-platform-icon {
  font-size: 24px; margin-bottom: 4px;
}
.lista-assistant-platform > strong {
  display: block; font-size: 14px; font-weight: 700;
  color: var(--ink); margin-bottom: 10px;
}
.lista-assistant-steps {
  margin: 0; padding-left: 22px;
  display: flex; flex-direction: column; gap: 6px;
}
.lista-assistant-steps li {
  font-size: 13px; color: var(--ink-2); line-height: 1.5;
}
.lista-assistant-steps li strong { color: var(--ink); }
.lista-assistant-steps li em { color: var(--moss); font-style: normal; font-weight: 500; }
.lista-assistant-dl {
  width: 100%; margin-top: 8px; text-decoration: none;
}

/* ============================================================
   Settings modal
   ============================================================ */

.settings-section + .settings-section {
  margin-top: 22px;
}

.settings-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 22px;
}

.settings-identity {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.settings-identity > div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-s);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
}

.settings-identity span,
.household-item span {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
}

.settings-identity strong,
.household-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.theme-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--stone);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.theme-opt {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 10px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
}

.theme-opt:hover { color: var(--ink); }

.theme-opt.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.theme-opt:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.household-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px auto;
  gap: 8px;
  align-items: center;
}

.settings-input {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  padding: 0 12px;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-enter);
}

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

.settings-input::placeholder {
  color: var(--ink-2);
  opacity: 0.65;
}

.household-reset {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 0 0;
  cursor: pointer;
}

.household-reset:hover {
  color: var(--danger);
}

.household-reset:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.household-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.household-list-title {
  margin: 4px 0 2px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.household-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.household-delete {
  flex-shrink: 0;
  width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
}

.household-delete:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.household-delete-confirm,
.household-delete-cancel {
  flex-shrink: 0;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 13px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.household-delete-confirm {
  border: 1px solid var(--danger);
  background: var(--danger);
  color: #fff;
}

.household-delete-cancel {
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink-2);
}

.household-item.pending-delete {
  border-color: var(--danger);
}

.household-confirm-note {
  display: block;
  margin-top: 4px;
  color: var(--danger) !important;
  font-size: 11px !important;
  font-weight: 600;
}

.household-delete:focus-visible,
.household-delete-confirm:focus-visible,
.household-delete-cancel:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.household-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border-s);
  border-radius: var(--radius-sm);
  background: var(--paper-2);
}

.household-item.active {
  border-color: var(--moss);
}

.household-item > div {
  min-width: 0;
}

.household-open,
.household-state,
.profile-use,
.profile-state {
  flex-shrink: 0;
  min-height: 32px;
  border-radius: 999px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
}

.household-open,
.profile-use {
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
}

.household-open:hover,
.profile-use:hover {
  border-color: var(--moss);
}

.household-open:focus-visible,
.profile-use:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.household-state,
.profile-state {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--moss);
  color: var(--moss);
  padding: 0 11px;
}

/* `.household-item span` (line ~2650) outranks `.household-state`; restore badge look. */
.household-item span.household-state {
  color: var(--moss);
  font-size: 12px;
  font-weight: 700;
}

.profile-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.profile-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 1px solid var(--border-s);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease-enter),
              background-color var(--dur-fast) var(--ease-enter);
}

.profile-row.active {
  border-color: var(--moss);
  background: var(--moss-tint);
}

.profile-row:focus-within {
  border-color: var(--moss);
}

.profile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  min-width: 0;
}

.profile-name-input {
  flex: 1;
  min-width: 110px;
  min-height: 36px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 0;
}

.profile-name-input:focus,
.profile-name-input:focus-visible {
  outline: none;
}

.profile-save {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  padding: 0 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
}

.profile-save:hover {
  border-color: var(--moss);
  color: var(--ink);
}

.profile-save:focus-visible {
  outline: 2px solid var(--moss);
  outline-offset: 2px;
}

.profile-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter);
}

.profile-remove:hover {
  background: var(--stone);
  color: var(--danger);
}

.profile-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

#profile-input:focus-visible {
  outline: none;
}

@media (max-width: 420px) {
  .settings-identity {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   Perfil tab
   ============================================================ */

.perfil-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.perfil-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-s);
}

.perfil-section:last-of-type {
  border-bottom: none;
}

.perfil-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.perfil-label {
  font-size: 13px;
  color: var(--ink-2);
  flex-shrink: 0;
  min-width: 80px;
}

.perfil-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  height: 44px;
  padding: 0 10px;
  width: 100px;
  text-align: right;
  appearance: textfield;
  -moz-appearance: textfield;
  transition: border-color var(--dur-fast) var(--ease-enter);
}

.perfil-input::-webkit-outer-spin-button,
.perfil-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.perfil-input[type="date"] {
  text-align: left;
  width: auto;
  min-width: 140px;
}

.perfil-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--moss-tint);
}

/* Input + unit suffix wrapper */
.perfil-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.perfil-input-wrap .perfil-input {
  padding-right: 34px;
}

.perfil-unit {
  position: absolute;
  right: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  pointer-events: none;
  user-select: none;
}

/* Segmented controls full-width inside form */
.perfil-section .segmented {
  display: flex;
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-group-wrap {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* .perfil-choice.active kept for .btn-secondary fallback */
.perfil-choice.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Segmented controls inside perfil form: accent active state
   (3-class specificity beats .segmented__opt.active from styles-components.css) */
.perfil-section .segmented .perfil-choice.active {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

/* Activity rows — vertical list with visible descriptions */
.perfil-activity-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.perfil-activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border-s);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter);
  -webkit-tap-highlight-color: transparent;
}

.perfil-activity-row:active {
  transform: scale(0.99);
}

.perfil-activity-row__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}

.perfil-activity-row__desc {
  font-size: 12px;
  color: var(--ink-3);
  text-align: right;
  line-height: 1.35;
}

.perfil-activity-row.active {
  background: var(--moss-tint);
  border-color: var(--accent);
}

.perfil-activity-row.active .perfil-activity-row__label {
  color: var(--accent);
}

.perfil-activity-row.active .perfil-activity-row__desc {
  color: var(--accent-soft);
}

/* Legacy small-button style (keep for any other usage) */
.perfil-activity {
  font-size: 12px;
  padding: 0 12px;
  min-height: 34px;
}

.perfil-warning {
  font-size: 12px;
  color: var(--danger);
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(181, 64, 58, 0.08);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--danger);
}

.perfil-warning.danger {
  font-weight: 600;
}

.perfil-targets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 110px;
  gap: 10px;
  margin-bottom: 24px;
}

.perfil-meta-card {
  padding: 14px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-top: 0;
}

.perfil-targets-grid > .perfil-meta-card {
  height: 100%;
}

.perfil-targets-grid > .card + .card {
  margin-top: 0;
}

/* ── Macro split (comida tab) ── */

.macro-split {
  font-size: 11px;
  color: var(--ink-2);
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.macro-split-name {
  font-weight: 600;
  color: var(--ink);
  margin-right: 4px;
}

/* ============================================================
   Casa tab — household task tracker
   ============================================================ */

.casa-wrap {
  padding: 16px 16px 32px;
  max-width: 600px;
  margin: 0 auto;
}

.casa-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.casa-title {
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-top: 2px;
}

.casa-person-totals {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-shrink: 0;
}

.casa-person-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-s);
  border-top-color: var(--edge-hi);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 56px;
  box-shadow: var(--shadow-card);
}

.casa-person-total-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 3px;
}

.casa-person-total-count {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  color: var(--moss);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.casa-winner {
  background: var(--moss-tint);
  border: 1px solid var(--moss-tint-2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
}

.casa-period {
  margin-bottom: 16px;
}

.casa-grid {
  background: var(--surface-2);
  border: 1px solid var(--border-s);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.casa-grid-head,
.casa-grid-row {
  display: grid;
  align-items: center;
  padding: 0 10px;
  gap: 4px;
}

.casa-grid-head {
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  height: 34px;
}

.casa-grid-task-hd {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.casa-grid-p-hd {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.casa-cat-hd {
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-3);
  border-top: 1px solid var(--border-s);
}

.casa-grid-row {
  min-height: 42px;
  border-top: 1px solid var(--border-s);
}

.casa-grid-row:hover {
  background: var(--surface-3);
}

.casa-grid-task-name {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.3;
}

.casa-grid-count {
  width: 40px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink-3);
  background: transparent;
  border: none;
  cursor: default;
  font-family: var(--font);
}

.casa-grid-count.has-n {
  background: var(--moss-tint);
  color: var(--moss);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-enter);
}

.casa-grid-count.has-n:hover {
  background: var(--moss-tint-2);
}

.casa-add-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-enter),
              color var(--dur-fast) var(--ease-enter),
              border-color var(--dur-fast) var(--ease-enter);
}

.casa-add-btn:hover {
  background: var(--moss);
  border-color: var(--moss);
  color: #fff;
}

.casa-recent {
  margin-bottom: 24px;
}

.casa-empty {
  font-size: 14px;
  color: var(--ink-3);
  padding: 4px 0;
  line-height: 1.5;
}

.casa-history {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border-s);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.casa-hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
}

.casa-hist-row + .casa-hist-row {
  border-top: 1px solid var(--border-s);
}

.casa-hist-info {
  flex: 1;
  min-width: 0;
}

.casa-hist-task {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.casa-hist-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 1px;
}

.casa-hist-photo {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur-fast);
  line-height: 1;
}

.casa-hist-photo:hover { background: var(--stone); }

.casa-hist-del {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast), color var(--dur-fast);
  font-family: var(--font);
}

.casa-hist-del:hover {
  background: var(--danger);
  color: #fff;
}

.casa-modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  line-height: 1.3;
}

.casa-grid-add-row {
  padding: 10px 10px;
  border-top: 1px solid var(--border-s);
  background: var(--surface-2);
}

.casa-new-task-btn {
  width: 100%;
  min-height: 40px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-3);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color var(--dur-fast), color var(--dur-fast), background-color var(--dur-fast);
}

.casa-new-task-btn:hover {
  border-color: var(--moss);
  color: var(--moss);
  background: var(--moss-tint);
}

.casa-del-task {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--stone);
  border: none;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
  font-family: var(--font);
  transition: background-color var(--dur-fast), color var(--dur-fast);
}

.casa-del-task:hover {
  background: var(--danger);
  color: #fff;
}

.casa-cat-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.casa-cat-opt {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}

.casa-cat-opt.active {
  background: var(--moss);
  border-color: var(--moss);
  color: #fff;
}
