/* =========================
   BAS
   ========================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, system-ui, sans-serif;
  background: #121212;
  color: #eee;
}

/* =========================
   HERO / STICKY HEADER
   ========================= */

.hero {
  position: sticky;
  top: 0;
  z-index: 10;
  background: radial-gradient(circle at top, #5fd38c, #2e7d32);
  border-radius: 0 0 26px 26px;
}

.hero.over {
  background: radial-gradient(circle at top, #ff8a80, #b71c1c);
}

.hero-inner {
  padding: 0.7rem 1rem 1rem;
}

/* App-namn / version */
.app-badge {
  text-align: center;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.85);
  margin-bottom: 0.3rem;
}

/* =========================
   HERO - DAG NAVIGERING
   ========================= */

.hero-daynav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.5rem;
  margin-bottom: 1rem;
}

.hero-daynav a {
  color: #fff;
  font-size: 1.8rem;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  transition: all 0.2s;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-daynav a:active {
  background: rgba(255,255,255,0.15);
  transform: scale(0.95);
}

.hero-daynav span {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* =========================
   SUMMARY / REMAINING
   ========================= */

.summary {
  margin: 0.6rem 0 0.8rem;
}

.summary-top {
  display: flex;
  justify-content: center;
  margin-bottom: 0.4rem;
}

.remaining {
  text-align: center;
  margin-bottom: 0.6rem;
}

.remaining .label {
  display: block;
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0.3rem;
}

.remaining .value {
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Progress line */
.progress-line {
  height: 12px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 0.6rem;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.progress-line > div {
  height: 100%;
  background: linear-gradient(90deg, #b9ffca, #4caf50);
  border-radius: 8px;
  transition: width 0.4s ease;
}

.hero.over .progress-line > div {
  background: linear-gradient(90deg, #ffd1d1, #ff8a80);
}

/* =========================
   MAKROKORT I HERO
   ========================= */

.macro-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.macro-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 0.7rem 0.5rem;
  font-size: 0.75rem;
  backdrop-filter: blur(10px);
}

.macro-card .title {
  opacity: 0.9;
}

.macro-card .numbers {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0.2rem 0 0.3rem;
}

.mini-bar {
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}

.mini-bar div {
  height: 100%;
  border-radius: 4px;
}

.carbs .mini-bar div   { background: #6c7cff; }
.protein .mini-bar div { background: #ff6aa2; }
.fat .mini-bar div     { background: #c59cff; }

/* =========================
   APP CONTENT
   ========================= */

.app {
  max-width: 420px;
  margin: 0 auto;
  padding: 1rem;
}

/* =========================
   CARDS
   ========================= */

.card {
  background: #1e1e1e;
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border: 1px solid #252525;
  transition: all 0.2s;
}

/* =========================
   SECTION HEADER
   ========================= */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.section-meta {
  font-size: 0.8rem;
  color: #aaa;
}

/* =========================
   TIMELINE (DAGENS INTAG)
   ========================= */

.timeline {
  position: relative;
  margin-left: 0.6rem;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #333;
}

.entry {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
  cursor: pointer;
  padding: 0.4rem;
  margin-left: -0.4rem;
  margin-right: -0.4rem;
  border-radius: 8px;
  transition: background 0.2s;
  position: relative;
}

.entry:active {
  background: rgba(255,255,255,0.05);
}

.entry-arrow {
  margin-left: auto;
  color: #666;
  font-size: 1.2rem;
  align-self: center;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4caf50;
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.content .name {
  font-size: 0.95rem;
}

.content .kcal {
  font-size: 0.8rem;
  color: #aaa;
}

/* =========================
   FORM
   ========================= */

input {
  width: 100%;
  padding: 0.7rem;
  border-radius: 10px;
  border: 1px solid #333;
  background: #2a2a2a;
  color: #eee;
  font-size: 0.95rem;
}

input::placeholder {
  color: #888;
}

textarea {
  width: 100%;
  padding: 0.7rem;
  border-radius: 10px;
  border: 1px solid #333;
  background: #2a2a2a;
  color: #eee;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

textarea::placeholder {
  color: #888;
}

#aiSuggestBtn {
  width: 100%;
  padding: 0.7rem;
  border-radius: 10px;
  border: 1px solid #4caf50;
  background: rgba(76, 175, 80, 0.1);
  color: #4caf50;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#aiSuggestBtn:active {
  background: rgba(76, 175, 80, 0.2);
  transform: scale(0.98);
}

#aiBox {
  margin-top: 0.6rem;
  padding: 0.8rem;
  border-radius: 12px;
  background: rgba(76, 175, 80, 0.05);
  border: 1px solid rgba(76, 175, 80, 0.2);
}

#runAi {
  width: 100%;
  padding: 0.7rem;
  margin-top: 0.6rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #4caf50, #45a049);
  color: white;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

#runAi:active {
  transform: scale(0.98);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0.6rem 0;
}

/* =========================
   FOOTER NAV
   ========================= */

.footer-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, #111 95%, transparent);
  display: flex;
  justify-content: space-around;
  padding: 0.7rem 0;
  padding-bottom: env(safe-area-inset-bottom, 0.7rem);
  border-top: 1px solid #2a2a2a;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.nav-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0.5rem 1.2rem;
  border-radius: 12px;
  min-width: 44px;
  min-height: 44px;
  text-decoration: none;
}

.nav-btn:active {
  background: rgba(255,255,255,0.05);
  transform: scale(0.95);
}

.nav-btn span {
  font-size: 0.7rem;
  font-weight: 500;
}

.nav-btn.active {
  color: #4caf50;
}

/* =========================
   FÖRBÄTTRAD BOTTOM SHEET
   ========================= */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 30;
}

.sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: -100%;
  background: #1a1a1a;
  border-radius: 24px 24px 0 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transition: bottom .3s cubic-bezier(0.4, 0.0, 0.2, 1);
  z-index: 40;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5);
}

.bottom-sheet.open {
  bottom: 0;
}

/* Sheet handle (iOS-stil) */
.sheet-handle {
  width: 36px;
  height: 5px;
  background: rgba(255,255,255,0.3);
  border-radius: 3px;
  margin: 0.6rem auto 0.8rem;
}

.sheet-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1rem 1rem;
  border-bottom: 1px solid #2a2a2a;
  position: relative;
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.sheet-close-btn {
  position: absolute;
  right: 1rem;
  top: 0.6rem;
  background: rgba(255,255,255,0.08);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.sheet-close-btn:active {
  background: rgba(255,255,255,0.15);
  transform: scale(0.95);
}

.sheet-content {
  padding: 1.2rem 1rem;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.sheet-subtitle {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  color: #aaa;
}

/* =========================
   FAVORITER SECTION
   ========================= */

.favorites-section {
  margin-bottom: 1.5rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #eee;
  margin-bottom: 0.8rem;
}

.title-icon {
  font-size: 1.1rem;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.favorite-card {
  background: linear-gradient(135deg, #2a2a2a, #1e1e1e);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.favorite-card:active {
  transform: scale(0.98);
  background: linear-gradient(135deg, #333, #2a2a2a);
  border-color: #4caf50;
}

.fav-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: #eee;
  margin-bottom: 0.4rem;
}

.fav-macros {
  font-size: 0.7rem;
  color: #888;
  line-height: 1.3;
}

/* Gamla favoriter (för bakåtkompatibilitet) */
.favorites {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.favorite-btn {
  background: #263d2c;
  color: #9be7b4;
  border: none;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* Favoriter - Delete mode */
.delete-favorites-btn {
  background: #8b4444;
  color: #ff9999;
  border: none;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

.delete-favorites-btn:hover {
  background: #a95555;
}

.delete-favorites-btn.active {
  background: #ff5252;
  color: white;
}

.favorite-item {
  position: relative;
  display: inline-block;
}

.favorite-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: #ff5252;
  color: white;
  border: 2px solid #121212;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s;
  z-index: 10;
}

.favorite-delete-btn:hover {
  background: #ff1744;
}

.favorite-item.delete-mode .favorite-delete-btn {
  display: flex;
}

.favorite-item.delete-mode .favorite-btn {
  opacity: 0.7;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: #666;
  font-size: 0.75rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #333;
}

.divider span {
  padding: 0 1rem;
}

/* =========================
   FORM STYLING
   ========================= */

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.4rem;
}

.label-icon {
  font-size: 1rem;
}

.form-input {
  width: 100%;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid #333;
  background: #2a2a2a;
  color: #eee;
  font-size: 1rem;
  transition: all 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #4caf50;
  background: #2d2d2d;
}

.form-input::placeholder {
  color: #666;
}

/* =========================
   MAKRO INPUT KORT
   ========================= */

.macro-input-section {
  margin: 1.2rem 0 1.5rem;
}

.section-title-small {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.8rem;
}

.macro-input-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
}

.macro-input-card {
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.macro-input-card:focus-within {
  border-color: #4caf50;
  background: #2d2d2d;
}

.macro-input-icon {
  font-size: 1.5rem;
  margin-bottom: 0.2rem;
}

.macro-input {
  width: 100%;
  padding: 0.5rem;
  border: none;
  background: rgba(255,255,255,0.05);
  color: #eee;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  border-radius: 8px;
}

.macro-input:focus {
  outline: none;
  background: rgba(255,255,255,0.08);
}

.macro-input::placeholder {
  color: #555;
}

.macro-input-label {
  font-size: 0.7rem;
  color: #888;
  text-align: center;
}

/* Färgaccenter för makro-kort */
.kcal-card:focus-within {
  border-color: #4caf50;
}

.protein-card:focus-within {
  border-color: #ff6aa2;
}

.fat-card:focus-within {
  border-color: #c59cff;
}

.carbs-card:focus-within {
  border-color: #6c7cff;
}

/* =========================
   PRIMARY BUTTON
   ========================= */

.primary-btn {
  width: 100%;
  padding: 1rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #4caf50, #45a049);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.primary-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.btn-icon {
  font-size: 1.2rem;
}

/* =========================
   GOALS / SETTINGS FORM
   ========================= */

.goal-section {
  background: linear-gradient(135deg, #2a2a2a, #1e1e1e);
  border: 1px solid #333;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.2rem;
}

.goal-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #9be7b4;
  margin: 0 0 0.8rem 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.goal-input-group {
  margin-bottom: 0.8rem;
}

.goal-input-group:last-child {
  margin-bottom: 0;
}

.goal-input-group label {
  display: block;
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 0.4rem;
}

.goal-input-group input {
  width: 100%;
  padding: 0.7rem;
  border-radius: 8px;
  border: 1px solid #333;
  background: #1a1a1a;
  color: #eee;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.goal-input-group input:focus {
  outline: none;
  border-color: #9be7b4;
  background: #1f1f1f;
}

.goal-display {
  background: rgba(155, 231, 180, 0.08);
  border: 1px solid #9be7b4;
  border-radius: 8px;
  padding: 0.8rem;
  margin-top: 0.8rem;
}

.display-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.display-label {
  color: #aaa;
}

.display-value {
  color: #9be7b4;
  font-weight: 600;
  font-size: 1.1rem;
}

.settings-info {
  background: rgba(100, 150, 200, 0.1);
  border: 1px solid #4a6fa5;
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 1rem;
}

/* =========================
   INTAG DETALJ-MODAL
   ========================= */

.intake-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 50;
  backdrop-filter: blur(4px);
}

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

.intake-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 360px;
  max-height: 80vh;
  background: #1e1e1e;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  z-index: 60;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.intake-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

/* Header */
.intake-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1rem 1rem;
  border-bottom: 1px solid #2a2a2a;
  background: #1a1a1a;
}

.intake-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #eee;
  flex: 1;
  padding-right: 1rem;
}

.modal-close {
  background: rgba(255,255,255,0.1);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.modal-close:active {
  background: rgba(255,255,255,0.15);
  transform: scale(0.95);
}

.modal-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* =========================
   MODAL ACTION BUTTONS
   ========================= */

.modal-buttons {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* Basstil för alla action-knappar */
.action-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;

  border: none;
  padding: 0.38rem 0.65rem;

  border-radius: 999px;

  font-size: 0.75rem;
  font-weight: 500;

  cursor: pointer;

  backdrop-filter: blur(10px);

  transition: all 0.15s ease;
}

.action-btn span {
  font-size: 0.72rem;
}

/* =========================
   FAVORIT
   ========================= */

.action-btn.favorite {
  background: rgba(76,175,80,0.15);
  color: #9be7b4;
}

.action-btn.favorite:hover {
  background: rgba(76,175,80,0.25);
}

/* =========================
   COPY
   ========================= */

.action-btn.copy {
  background: rgba(100,181,246,0.15);
  color: #64b5f6;
}

.action-btn.copy:hover {
  background: rgba(100,181,246,0.25);
}

/* =========================
   DELETE
   ========================= */

.action-btn.delete {
  background: rgba(239,83,80,0.15);
  color: #ef5350;
}

.action-btn.delete:hover {
  background: rgba(239,83,80,0.25);
}

/* Klick-feedback */
.action-btn:active {
  transform: scale(0.92);
}







/* Content */
.intake-modal-content {
  padding: 1.2rem 1rem;
  overflow-y: auto;
  flex: 1;
}

/* Stora kcal */
.intake-kcal-big {
  text-align: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: #4caf50;
  margin-bottom: 1.5rem;
}

/* Makro-cirklar */
.intake-macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.intake-macro-circle {
  text-align: center;
}

.circular-chart {
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.circle-bg {
  fill: none;
  stroke: rgba(255,255,255,0.1);
  stroke-width: 3.8;
}

.circle {
  fill: none;
  stroke-width: 3.8;
  stroke-linecap: round;
  animation: progress 0.6s ease-out forwards;
}

.protein-circle {
  stroke: #ff6aa2;
}

.fat-circle {
  stroke: #c59cff;
}

.carbs-circle {
  stroke: #6c7cff;
}

@keyframes progress {
  from {
    stroke-dasharray: 0 100;
  }
}

.percentage {
  fill: #eee;
  font-size: 0.5em;
  text-anchor: middle;
  font-weight: 600;
}

.macro-label {
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 0.4rem;
}

.macro-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: #eee;
  margin-top: 0.2rem;
}

/* Jämförelse mot mål */
.intake-comparison {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 1rem;
}

.comparison-title {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.8rem;
  text-align: center;
}

.comparison-row {
  display: grid;
  grid-template-columns: 80px 1fr 40px;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.comparison-row:last-child {
  margin-bottom: 0;
}

.comparison-label {
  font-size: 0.8rem;
  color: #bbb;
}

.comparison-bar {
  height: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  overflow: hidden;
}

.comparison-fill {
  height: 100%;
  background: #4caf50;
  border-radius: 6px;
  transition: width 0.4s ease;
}

.comparison-fill.protein {
  background: #ff6aa2;
}

.comparison-fill.fat {
  background: #c59cff;
}

.comparison-fill.carbs {
  background: #6c7cff;
}

.comparison-pct {
  font-size: 0.8rem;
  color: #aaa;
  text-align: right;
}

/* =========================
   VECKOVY
   ========================= */

.week-card {
  position: relative;
}

.week-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.8rem;
}

.week-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.week-meta {
  font-size: 0.8rem;
  color: #aaa;
}

.week-submeta {
  font-size: 0.75rem;
  color: #aaa;
  margin-bottom: 0.6rem;
}

/* Staplar */
.week-bars {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 160px;
  padding: 0 0.2rem;
}

.day-bar {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: inherit;
  padding: 0.3rem;
  border-radius: 8px;
  transition: all 0.2s;
}

.day-bar:active {
  background: rgba(255,255,255,0.05);
  transform: scale(0.98);
}

.bar-wrap {
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar-fill {
  width: 70%;
  background: #4caf50;
  border-radius: 6px 6px 0 0;
  transition: height .25s;
}

.day-bar.over .bar-fill {
  background: #ff8a80;
}

.day-label {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: #aaa;
}

.week-insights-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.9rem;
  color: #aaa;
}

.week-insights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.insight-card {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 0.7rem;
  text-align: center;
}

.insight-card .label {
  font-size: 0.7rem;
  color: #aaa;
}

.insight-card .value {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.2rem 0;
}

.insight-card .value.negative {
  color: #ff8a80;
}

.insight-card .value.positive {
  color: #81c784;
}

.insight-card .hint {
  font-size: 0.65rem;
  color: #777;
}

.week-extremes {
  margin-top: 0.8rem;
  font-size: 0.75rem;
  color: #aaa;
  text-align: center;
}

/* =========================
   MAKROFÖRDELNING
   ========================= */

.macro-distribution {
  background: #1a1a1a;
  border-radius: 14px;
  padding: 1rem;
}

/* Visuell stapel */
.macro-bar {
  display: flex;
  height: 42px;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.macro-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  transition: all 0.3s ease;
  position: relative;
}

.macro-segment span {
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.macro-segment:hover span,
.macro-segment:focus span {
  opacity: 1;
}

.macro-segment.protein {
  background: linear-gradient(135deg, #ff6aa2, #ff4d8f);
}

.macro-segment.fat {
  background: linear-gradient(135deg, #c59cff, #a779ff);
}

.macro-segment.carbs {
  background: linear-gradient(135deg, #6c7cff, #4d5eff);
}

/* Breakdown lista */
.macro-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.macro-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.macro-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.macro-dot.protein {
  background: #ff6aa2;
}

.macro-dot.fat {
  background: #c59cff;
}

.macro-dot.carbs {
  background: #6c7cff;
}

.macro-info {
  flex: 1;
}

.macro-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: #eee;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.macro-diff {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
}

.macro-diff.positive {
  background: rgba(129, 199, 132, 0.2);
  color: #81c784;
}

.macro-diff.negative {
  background: rgba(255, 138, 128, 0.2);
  color: #ff8a80;
}

.macro-goal {
  color: #666;
  font-style: italic;
}

/* Tips-ruta */
.macro-tip {
  background: rgba(155, 231, 180, 0.1);
  border-left: 3px solid #9be7b4;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #9be7b4;
  line-height: 1.4;
}

/* =========================
   DEFICIT/ÖVERSKOTT CARD
   ========================= */

.deficit-card {
  background: #1e1e1e;
  border-radius: 16px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}

.deficit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.deficit-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #eee;
}

.deficit-mode {
  font-size: 0.75rem;
  color: #aaa;
  background: rgba(255,255,255,0.05);
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
}

/* Progress visualisering */
.deficit-progress {
  margin: 1.2rem 0;
}

.deficit-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: #888;
  margin-bottom: 0.5rem;
}

.label-center {
  color: #9be7b4;
  font-weight: 600;
}

.deficit-bar-track {
  position: relative;
  height: 32px;
  background: linear-gradient(to right, 
    rgba(255, 138, 128, 0.15) 0%, 
    rgba(155, 231, 180, 0.15) 100%);
  border-radius: 12px;
  overflow: visible;
}

/* Planerad deficit - markering */
.deficit-target {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: #9be7b4;
  box-shadow: 0 0 8px rgba(155, 231, 180, 0.6);
  transform: translateX(-50%);
  z-index: 2;
}

.deficit-target::before {
  content: "Mål";
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: #9be7b4;
  white-space: nowrap;
}

/* Faktisk deficit - fylld stapel */
.deficit-actual {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #ff8a80, #ff6b9d);
  border-radius: 12px;
  transition: width 0.4s ease;
}

/* Stats grid */
.deficit-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 1rem 0;
}

.deficit-stat {
  background: #1a1a1a;
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
}

.stat-label {
  font-size: 0.65rem;
  color: #888;
  margin-bottom: 0.3rem;
}

.stat-value {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.stat-value.deficit {
  color: #ff8a80;
}

.stat-value.surplus {
  color: #81c784;
}

.stat-value.over {
  color: #ffb74d;
}

.stat-value.under {
  color: #64b5f6;
}

.stat-value.neutral {
  color: #aaa;
}

.stat-hint {
  font-size: 0.65rem;
  color: #666;
}

/* Insight box */
.deficit-insight {
  background: rgba(155, 231, 180, 0.1);
  border-left: 3px solid #9be7b4;
  padding: 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #9be7b4;
  line-height: 1.5;
}

/* =========================
   RESPONSIV (små iPhones)
   ========================= */

@media (max-width: 380px) {
  .favorites-grid {
    grid-template-columns: 1fr;
  }
  
  .macro-input-cards {
    grid-template-columns: 1fr;
  }
  
  .circular-chart {
    width: 70px;
    height: 70px;
  }
  
  .intake-kcal-big {
    font-size: 1.8rem;
  }
  
  .intake-modal {
    width: 95%;
  }
  
  .deficit-stats {
    grid-template-columns: 1fr;
  }
  
  .deficit-labels {
    font-size: 0.6rem;
  }
  
  .label-center {
    display: none;
  }
}

/* =========================
   iPHONE SAFE AREA SUPPORT
   ========================= */

@supports (padding: max(0px)) {
  .hero {
    padding-top: env(safe-area-inset-top);
  }
  
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .sheet-content {
    padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
  }
  
  .intake-modal {
    max-height: calc(80vh - env(safe-area-inset-bottom));
  }
}

/* =========================
   DARK MODE MED OLED-OPTIMERING
   ========================= */

@media (prefers-color-scheme: dark) {
  body {
    background: #000;
  }
  
  .card {
    background: #1a1a1a;
  }
}

/* =========================
   SMOOTH ANIMATIONS
   ========================= */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Haptic feedback simulation */
button:active,
.entry:active,
.favorite-card:active {
  transition: transform 0.1s;
}

/* ================= GROK FEEDBACK MODAL ================= */
.grok-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 1000;
  animation: fadeIn 0.3s;
}

.grok-backdrop.show {
  display: block;
}

.grok-modal {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-radius: 24px 24px 0 0;
  max-height: 90vh;
  overflow: hidden;
  z-index: 1001;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.grok-modal.open {
  display: block;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.grok-header {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  padding: 1.5rem;
  position: relative;
}

.grok-header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.grok-icon {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.75rem;
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.grok-title h2 {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.grok-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.875rem;
  margin: 0.25rem 0 0 0;
}

.grok-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}

.grok-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.grok-content {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 100px);
  -webkit-overflow-scrolling: touch;
}

.grok-loading {
  text-align: center;
  padding: 3rem 1rem;
}

.grok-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(139, 92, 246, 0.2);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.grok-loading-text {
  color: #94a3b8;
  font-size: 0.875rem;
}

.grok-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: start;
}

.grok-error-icon {
  color: #f87171;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.grok-error-content h3 {
  color: #fca5a5;
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

.grok-error-content p {
  color: #fecaca;
  margin: 0;
  font-size: 0.875rem;
}

.grok-retry {
  margin-top: 0.75rem;
  background: rgba(239, 68, 68, 0.2);
  border: none;
  color: #fca5a5;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.grok-retry:hover {
  background: rgba(239, 68, 68, 0.3);
}

.grok-sections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grok-section {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.2s;
}

.grok-section:hover {
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateY(-2px);
}

.grok-section.advice {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
  border-color: rgba(139, 92, 246, 0.3);
}

.grok-section.reflektion {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 1.25rem;
}

.grok-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.grok-section-icon {
  font-size: 1.25rem;
}

.grok-section-title {
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.grok-section-content {
  color: #cbd5e1;
  line-height: 1.7;
  font-size: 0.9375rem;
  white-space: pre-line;
}

.grok-section.advice .grok-section-content {
  color: #e9d5ff;
  font-weight: 500;
}

.grok-section.reflektion .grok-section-content {
  color: #e0e7ff;
  line-height: 1.8;
  font-size: 0.95rem;
}

.grok-refresh {
  width: 100%;
  margin-top: 1rem;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  border: none;
  color: white;
  padding: 0.875rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all 0.2s;
}

.grok-refresh:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

.grok-refresh:active {
  transform: translateY(0);
}

/* Floating Action Button för Grok */
.grok-fab {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.5);
  transition: all 0.3s;
  z-index: 100;
}

.grok-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(139, 92, 246, 0.6);
}

.grok-fab:active {
  transform: scale(0.95);
}

@media (min-width: 640px) {
  .grok-modal {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    border-radius: 24px;
    bottom: auto;
    top: 50%;
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  @keyframes modalSlide {
    from {
      transform: translate(-50%, -48%) scale(0.9);
      opacity: 0;
    }
    to {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }
  }
  
  .grok-modal.open {
    transform: translate(-50%, -50%);
  }
}

.stat-total {
  font-size: 0.75rem;
  opacity: 0.6;
  display: block;
  margin-top: 0.25rem;
}

/* ================= VIKT DISPLAY ================= */

.current-weight-display {
  background: linear-gradient(135deg, #2a2a2a, #1e1e1e);
  border: 1px solid #4caf50;
  border-radius: 16px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.current-weight-label {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.5rem;
}

.current-weight-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: #4caf50;
  margin-bottom: 0.3rem;
}

.current-weight-hint {
  font-size: 0.75rem;
  color: #888;
}

/* =========================
   AI QUICK ADD
   ========================= */

.ai-assistant {
  margin: 0.8rem 0 1rem;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 0.8rem;
}

.ai-toggle {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid #2a2a2a;
  color: #aaa;
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  transition: all 0.2s;
}

.ai-toggle:active {
  background: rgba(255,255,255,0.08);
  transform: scale(0.98);
}

.ai-toggle span {
  opacity: 0.8;
}

.ai-box {
  margin-top: 0.7rem;
  display: none;
}

.ai-box textarea {
  width: 100%;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 10px;
  color: #eee;
  padding: 0.7rem;
  font-size: 0.9rem;
  resize: none;
  min-height: 60px;
}

.ai-box textarea::placeholder {
  color: #777;
}

.ai-run {
  margin-top: 0.6rem;
  width: 100%;
  background: linear-gradient(135deg,#4caf50,#43a047);
  border: none;
  border-radius: 10px;
  padding: 0.7rem;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-run:active {
  transform: scale(0.97);
}

.ai-loading {
  opacity: 0.6;
  animation: pulse 1s infinite;
}