/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

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

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: 0 0 24px color-mix(in srgb, var(--tint) 25%, transparent);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--glass-border-hover);
}

/* Split button: estimation text + camera */
.estimate-btn-group {
  display: flex;
  width: 100%;
  gap: 0;
}

.estimate-btn-text {
  flex: 1;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  min-width: 0;
}

.estimate-btn-icon {
  flex: none;
  width: 48px;
  padding: 0;
  border-radius: 0;
  border-left: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.estimate-btn-icon:last-of-type {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.estimate-btn-icon svg {
  pointer-events: none;
  width: 26px;
  height: 26px;
}

.estimate-btn-icon.mic-recording {
  background: color-mix(in srgb, var(--red) 20%, transparent);
  color: var(--red);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 50%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--red) 0%, transparent); }
}

/* Estimate summary (2-line max + inline "Voir plus") */
.estimate-summary-wrap {
  width: 100%;
  margin-top: 4px;
  position: relative;
  max-height: 2.8em;
  overflow: hidden;
  font-size: 0.75rem;
  line-height: 1.4;
}

.estimate-summary-text {
  color: var(--text-muted);
  font-style: italic;
}

.estimate-see-more {
  position: absolute;
  right: 0;
  bottom: 0;
  color: var(--accent);
  cursor: pointer;
  font-style: normal;
  font-weight: 600;
  background: linear-gradient(to right, transparent, var(--bg-primary) 30%);
  padding-left: 2em;
}

.estimate-see-more:hover {
  text-decoration: underline;
}

/* Estimate details popup */
.estimate-details-popup h3 {
  color: var(--accent);
}

.estimate-details-macros {
  font-size: 0.85rem;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-md);
  line-height: 1.6;
}

.estimate-details-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--sp-md);
}

.estimate-details-content a {
  color: var(--accent);
  word-break: break-all;
}

.estimate-details-content a:hover {
  text-decoration: underline;
}

/* Estimate chat popup */
.hint-popup.estimate-chat-popup {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  max-width: 560px;
  width: 94%;
}

@media (min-width: 768px) {
  .hint-popup.estimate-chat-popup {
    max-width: 75vw;
    width: 75vw;
  }
  .hint-popup.estimate-chat-popup .estimate-chat-messages {
    max-height: 65vh;
  }
}

@media (min-width: 1400px) {
  .hint-popup.estimate-chat-popup {
    max-width: 60vw;
  }
}

.estimate-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-sm);
}

.estimate-chat-header h3 {
  margin-bottom: 0;
}

.estimate-chat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.estimate-chat-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.estimate-chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: var(--sp-md);
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  max-height: 50vh;
  min-height: 120px;
}

.estimate-chat-msg {
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 95%;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.estimate-chat-msg.assistant {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  align-self: flex-start;
}

.estimate-chat-msg.user {
  background: var(--accent-bg);
  border: 1px solid color-mix(in srgb, var(--tint) 20%, transparent);
  align-self: flex-end;
  color: var(--text-primary);
}

.estimate-chat-msg.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.estimate-chat-macros {
  font-size: 0.82rem;
  margin-bottom: 4px;
  line-height: 1.6;
}

.estimate-chat-summary {
  color: var(--text-primary);
  font-style: italic;
  font-size: 0.82rem;
  margin-top: 4px;
}

.estimate-chat-details {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 6px;
  line-height: 1.5;
}

.estimate-chat-details a {
  color: var(--accent);
  word-break: break-all;
}

.estimate-chat-text {
  font-size: 0.83rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.estimate-chat-text a {
  color: var(--accent);
  word-break: break-all;
}

.estimate-chat-text strong {
  font-weight: 600;
  color: var(--text-primary);
}

.estimate-chat-text ul,
.estimate-chat-text ol {
  margin: 4px 0;
  padding-left: 20px;
}

.estimate-chat-text li {
  line-height: 1.5;
  margin: 1px 0;
}

.estimate-chat-text p {
  margin: 4px 0;
}

.estimate-chat-details ul,
.estimate-chat-details ol {
  margin: 4px 0;
  padding-left: 20px;
}

.estimate-chat-details li {
  line-height: 1.5;
  margin: 1px 0;
}

.estimate-chat-apply {
  margin-top: 6px;
  width: auto;
  padding: 3px 10px !important;
  font-size: 0.72rem !important;
  background: transparent;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--tint) 30%, transparent);
}

.estimate-chat-apply:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.estimate-chat-input-row {
  display: flex;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-sm);
}

.estimate-chat-input-row .input {
  flex: 1;
}

.estimate-chat-input-row .btn {
  flex-shrink: 0;
}

.estimate-chat-mic {
  width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.estimate-chat-mic svg {
  pointer-events: none;
  width: 20px;
  height: 20px;
}

.estimate-chat-mic.mic-recording {
  background: color-mix(in srgb, var(--red) 20%, transparent);
  color: var(--red);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

.estimate-chat-limit {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  margin-bottom: var(--sp-sm);
}

/* Footer: selected values + Valider */
.estimate-chat-footer {
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-primary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-sm);
}

.estimate-chat-footer-macros {
  flex: 1;
  font-size: 0.8rem;
  line-height: 1.4;
}

/* Loading / typing indicator */
.estimate-chat-loading {
  padding: var(--sp-sm) var(--sp-md);
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 20px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* Provider badge */
.provider-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.4;
  flex-shrink: 0;
}

.provider-codex {
  background: rgba(16, 163, 127, 0.15);
  color: #10a37f;
}

.provider-base {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.provider-groq {
  background: rgba(244, 114, 55, 0.15);
  color: #f47237;
}

.provider-web {
  background: color-mix(in srgb, var(--blue) 15%, transparent);
  color: var(--blue);
  cursor: help;
}

.estimate-chat-msg .provider-badge {
  margin-bottom: 4px;
}

.btn-danger {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--red) 20%, transparent);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--red) 20%, transparent);
  border-color: color-mix(in srgb, var(--red) 40%, transparent);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.8rem;
}

.btn-loading {
  pointer-events: none;
  animation: rainbow-glow 2s linear infinite;
  border-color: transparent;
  gap: 0;
}

.btn-loading::after {
  content: '...';
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  animation: loading-dots 1.2s steps(3, end) infinite;
}

@keyframes loading-dots {
  to { width: 1.2em; }
}

@keyframes rainbow-glow {
  0%   { box-shadow: 0 0 8px 2px var(--tint), 0 0 20px 4px color-mix(in srgb, var(--tint) 30%, transparent); border-color: var(--tint); }
  25%  { box-shadow: 0 0 8px 2px #a855f7, 0 0 20px 4px rgba(168,85,247,0.3); border-color: #a855f7; }
  50%  { box-shadow: 0 0 8px 2px var(--blue), 0 0 20px 4px color-mix(in srgb, var(--blue) 30%, transparent); border-color: var(--blue); }
  75%  { box-shadow: 0 0 8px 2px var(--green), 0 0 20px 4px color-mix(in srgb, var(--green) 30%, transparent); border-color: var(--green); }
  100% { box-shadow: 0 0 8px 2px var(--tint), 0 0 20px 4px color-mix(in srgb, var(--tint) 30%, transparent); border-color: var(--tint); }
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
}

/* ========================================
   INPUTS
   ======================================== */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 8%, transparent);
}

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

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7694' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ========================================
   NAME INPUT WITH HINT BULB
   ======================================== */
.name-input-wrap {
  position: relative;
}

.name-input-wrap .input {
  padding-right: 40px;
}

.hint-bulb {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  animation: bulb-glow 2s ease-in-out infinite;
}

@keyframes bulb-glow {
  0%, 100% {
    filter: drop-shadow(0 0 2px color-mix(in srgb, var(--green) 30%, transparent));
  }
  50% {
    filter: drop-shadow(0 0 8px color-mix(in srgb, var(--green) 70%, transparent)) drop-shadow(0 0 16px color-mix(in srgb, var(--green) 30%, transparent));
  }
}

.hint-bulb:hover {
  color: var(--green);
  animation: none;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--green) 80%, transparent));
}

/* Hint popup */
.hint-popup-overlay {
  position: fixed;
  inset: 0;
  background: var(--veil);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.hint-popup-overlay.active {
  opacity: 1;
}

.hint-popup {
  background: var(--bg-card-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-xl);
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.hint-popup h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: var(--sp-md);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.hint-popup p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--sp-md);
}

.hint-popup strong {
  color: var(--text-primary);
}

.hint-popup .hint-example {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--green);
  border-radius: var(--radius-md);
  padding: var(--sp-sm) var(--sp-md);
  font-size: 0.82rem;
  color: var(--text-primary);
  margin-bottom: var(--sp-md);
  font-family: var(--font-mono);
  line-height: 1.5;
}

.hint-popup ul {
  list-style: none;
  padding: 0;
  margin-bottom: var(--sp-md);
}

.hint-popup ul li {
  font-size: 0.83rem;
  color: var(--text-secondary);
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.hint-popup ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.hint-popup .hint-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--sp-md);
  line-height: 1.5;
}

.hint-popup .hint-close {
  display: block;
  width: 100%;
  margin-top: var(--sp-md);
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hint-popup .hint-close:hover {
  background: var(--bg-elevated);
  border-color: var(--green);
  color: var(--green);
}

/* ========================================
   FORM GROUPS
   ======================================== */
.form-group {
  margin-bottom: var(--sp-md);
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

/* ========================================
   DEFICIT SLIDER
   ======================================== */
.deficit-slider-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.deficit-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  background: linear-gradient(to right,
    #7B1818 0%, #7B1818 12.5%,
    #E53935 37.5%, #E53935 48.5%,
    #FB8C00 51.5%, #FB8C00 61%,
    #FDD835 64%, #FDD835 73.5%,
    #43A047 76.5%, #43A047 86%,
    #1E88E5 89%, #1E88E5 100%
  );
  border-radius: 4px;
  outline: none;
}

.deficit-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4), 0 0 8px rgba(0, 0, 0, 0.15);
  transition: box-shadow 0.2s ease;
}

.deficit-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 0, 0, 0.2);
}

.deficit-slider::-moz-range-track {
  height: 8px;
  background: linear-gradient(to right,
    #7B1818 0%, #7B1818 12.5%,
    #E53935 37.5%, #E53935 48.5%,
    #FB8C00 51.5%, #FB8C00 61%,
    #FDD835 64%, #FDD835 73.5%,
    #43A047 76.5%, #43A047 86%,
    #1E88E5 89%, #1E88E5 100%
  );
  border-radius: 4px;
  border: none;
}

.deficit-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4), 0 0 8px rgba(0, 0, 0, 0.15);
}

.deficit-slider-pct {
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-bright);
  min-width: 40px;
  text-align: right;
}

.deficit-slider-info {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-top: 6px;
}

.deficit-slider-warning {
  font-size: 0.78rem;
  margin-top: 6px;
  line-height: 1.4;
}

.form-row {
  display: flex;
  gap: var(--sp-sm);
}

.form-row > * {
  flex: 1;
}

/* ========================================
   TABS
   ======================================== */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--sp-lg);
}

.tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
}

/* ========================================
   SEARCH RESULTS
   ======================================== */
.search-results {
  max-height: 40vh;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-top: 6px;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
  gap: 8px;
}

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

.search-result-item:hover {
  background: var(--accent-bg);
}

.search-result-item .result-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-item .result-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Temporary history popup */
.temp-history-results {
  max-height: 55vh;
}

.temp-history-item {
  align-items: flex-start;
  padding: 10px 12px;
}

.temp-history-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.temp-history-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.temp-history-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.temp-history-meta {
  font-size: 0.78rem;
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.temp-history-meta .copy-bar-kcal {
  color: var(--accent);
  font-weight: 700;
}

.temp-history-meta .macro-p { color: var(--protein-color); }
.temp-history-meta .macro-l { color: var(--warning); }
.temp-history-meta .macro-g { color: var(--success); }

.temp-history-preview .copy-bar-kcal {
  color: var(--accent);
  font-weight: 700;
}

.temp-history-preview .macro-p { color: var(--protein-color); font-weight: 500; }
.temp-history-preview .macro-l { color: var(--warning); font-weight: 500; }
.temp-history-preview .macro-g { color: var(--success); font-weight: 500; }

/* Export modal */
.export-range-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.export-range-tabs .period-btn {
  flex: 1 1 auto;
  min-width: 80px;
}

.export-custom-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
}

.export-custom-row .input {
  flex: 1;
  min-width: 130px;
}

/* Recipe note displayed before the qty form */
.item-note-display {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--bg-primary);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  line-height: 1.4;
}

.temp-history-qty {
  color: var(--text-muted);
  font-weight: 400;
}

.temp-history-count {
  flex-shrink: 0;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  align-self: flex-start;
}

/* ========================================
   ITEM LIST
   ======================================== */
.item-list-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.item-list-entry:hover {
  background: var(--bg-hover);
}

.item-list-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.item-list-topline {
  display: flex;
  align-items: baseline;
  overflow: hidden;
  min-width: 0;
}

.item-list-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}

.item-list-kcal {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 6px;
}

.item-list-macros {
  display: flex;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
}

.item-list-macros .macro-p { color: var(--protein-color); }
.item-list-macros .macro-l { color: var(--warning); }
.item-list-macros .macro-g { color: var(--success); }

.item-mode-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--tint) 15%, transparent);
}

/* Composite mode hint */
.composite-hint {
  margin-bottom: var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
}

.composite-hint p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ========================================
   COMPOSITE NUTRITION SUMMARY
   ======================================== */
.composite-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-md);
}

.composite-summary-kcal {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.composite-summary-macro {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ========================================
   COMPOSITE COMPONENTS
   ======================================== */
.component-row {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
  margin-bottom: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.component-row .input {
  font-size: 0.85rem;
}

.component-remove {
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.component-remove:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--red) 8%, transparent);
}

/* ========================================
   STATS PERIOD SELECTOR
   ======================================== */
.period-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--sp-lg);
}

.period-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

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

.period-btn.active {
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
}

.incomplete-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--sp-md);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.incomplete-toggle small {
  color: var(--text-muted);
}

/* ========================================
   STATS SUMMARY
   ======================================== */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--sp-xs);
  margin-top: var(--sp-lg);
}

@media (max-width: 900px) {
  .stats-summary {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stats-summary .summary-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  padding: var(--sp-sm) var(--sp-xs);
  border-radius: var(--radius-md);
  text-align: center;
}

.stats-summary .summary-card .summary-value {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-bright);
}

.stats-summary .summary-card .summary-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast {
  position: fixed;
  bottom: var(--sp-lg);
  right: var(--sp-lg);
  transform: translateX(120%);
  background: var(--bg-card-solid);
  color: var(--text-primary);
  padding: 10px var(--sp-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--accent);
  max-width: calc(100vw - 2 * var(--sp-lg));
}

.toast.show {
  transform: translateX(0);
}

.toast.error {
  border-left-color: var(--danger);
}

/* ========================================
   RESPONSIVE MOBILE (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {

  /* Bigger touch targets for inputs */
  .input {
    padding: 12px 14px;
    font-size: 1rem;
  }

  .btn {
    padding: 12px 18px;
    font-size: 0.9rem;
  }

  /* Tabs: smaller text to fit 4 tabs */
  .tab {
    padding: 8px 6px;
    font-size: 0.72rem;
  }

  /* Period selector */
  .period-selector {
    flex-wrap: wrap;
  }

  .period-btn {
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  /* Stats summary: 2 columns on mobile */
  .stats-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Component rows */
  .component-row {
    flex-wrap: wrap;
  }

  /* Toast: full width but still bottom-right slide on mobile */
  .toast {
    bottom: calc(var(--tabbar-h, 0px) + env(safe-area-inset-bottom) + var(--sp-md));
    left: var(--sp-md);
    right: var(--sp-md);
    text-align: center;
    transform: translateY(120%);
  }

  .toast.show {
    transform: translateY(0);
  }
}

/* ========================================
   RESPONSIVE SMALL PHONE (max-width: 480px)
   ======================================== */
@media (max-width: 480px) {

  .period-btn {
    padding: 6px 8px;
    font-size: 0.7rem;
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  .component-row .input[type="number"],
  .component-row select.input {
    width: 56px;
    flex: none;
    font-size: 0.8rem;
    padding: 8px 6px;
  }

  .form-row {
    flex-direction: column;
    gap: var(--sp-sm);
  }

  .tab {
    padding: 7px 4px;
    font-size: 0.68rem;
  }

  .stats-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-xs);
  }

  .hint-popup {
    width: 95%;
    padding: var(--sp-md);
  }

  .hint-popup h3 {
    font-size: 0.9rem;
  }

  .hint-popup p,
  .hint-popup ul li {
    font-size: 0.78rem;
  }

  .hint-popup .hint-example {
    font-size: 0.75rem;
  }
}

/* Réglages du compte */
.settings-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 4px 0 12px;
  color: var(--text-primary);
}

.settings-section {
  margin-top: 28px;
}

.settings-danger-title {
  margin-top: 28px;
  color: var(--danger);
}


.settings-btn {
  width: 100%;
  margin-top: 8px;
}

.settings-delete-zone {
  margin-top: 12px;
}

.item-list-add {
  flex: none;
  padding: 4px 10px;
  font-size: 0.7rem;
}

/* ========================================
   PROFIL : DEUX BLOCS + AVANCÉ
   ======================================== */
.profile-section {
  padding: 16px 18px 4px;
  margin-bottom: 14px;
  background: var(--bg-secondary);
  border-radius: 20px;
}

.profile-section-title {
  margin-bottom: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-advanced {
  margin-bottom: var(--sp-md);
  padding: 0 4px;
}

.profile-advanced > summary {
  padding: 10px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.profile-advanced[open] > summary {
  margin-bottom: 6px;
}
