/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* ── Mörkt läge (standard) ── */
  --bg:          #0d0d11;
  --bg-card:     #16161e;
  --bg-input:    #1e1e2a;
  --border:      #2c2c3e;
  --border-hover:#484860;
  --accent:      #a78bfa;
  --accent-dark: #7c3aed;
  --accent-glow: rgba(167,139,250,.15);
  --green:       #34d399;
  --green-bg:    rgba(52,211,153,.12);
  --red:         #f87171;
  --red-bg:      rgba(248,113,113,.12);
  --gold:        #fbbf24;
  --cyan:        #38bdf8;
  --orange:      #fb923c;
  --text:        #eeeef6;
  --text-muted:  #9898c0;   /* fixad: var #7070a0 klarade ej WCAG AA */
  --text-dim:    #7070a0;   /* fixad: var #4a4a6a hade kontrast 1.6:1 */
  --radius:      14px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
}

/* ── Ljust läge: via systeminställning (ej explicit mörkt) ── */
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    --bg:          #f4f5f9;
    --bg-card:     #ffffff;
    --bg-input:    #eceef5;
    --border:      #d4d8e8;
    --border-hover:#adb4cc;
    --accent:      #6d28d9;
    --accent-dark: #5b21b6;
    --accent-glow: rgba(109,40,217,.1);
    --green:       #059669;
    --green-bg:    rgba(5,150,105,.1);
    --red:         #dc2626;
    --red-bg:      rgba(220,38,38,.1);
    --gold:        #b45309;
    --cyan:        #0369a1;
    --orange:      #c2410c;
    --text:        #111827;
    --text-muted:  #374151;
    --text-dim:    #6b7280;
    --shadow:      0 4px 24px rgba(0,0,0,.1);
  }
  html:not([data-theme="dark"]) header             { background: rgba(244,245,249,.95); }
  html:not([data-theme="dark"]) .hero              { background: linear-gradient(135deg, #f0edff 0%, #ebe5ff 60%, #eaf5f0 100%); }
  html:not([data-theme="dark"]) .hero::before      { background: radial-gradient(circle, rgba(109,40,217,.08) 0%, transparent 70%); }
  html:not([data-theme="dark"]) .landing-hero      { background: linear-gradient(180deg, rgba(109,40,217,.05) 0%, transparent 100%); }
  html:not([data-theme="dark"]) .landing-bottom-cta{ background: linear-gradient(135deg, rgba(109,40,217,.06), rgba(5,150,105,.03)); }
  html:not([data-theme="dark"]) .skeleton          { background: linear-gradient(90deg, #eef0f6 25%, #e4e7f0 50%, #eef0f6 75%); background-size: 200% 100%; }
}

/* ── Ljust läge: explicit val av användaren ── */
html[data-theme="light"] {
  --bg:          #f4f5f9;
  --bg-card:     #ffffff;
  --bg-input:    #eceef5;
  --border:      #d4d8e8;
  --border-hover:#adb4cc;
  --accent:      #6d28d9;
  --accent-dark: #5b21b6;
  --accent-glow: rgba(109,40,217,.1);
  --green:       #059669;
  --green-bg:    rgba(5,150,105,.1);
  --red:         #dc2626;
  --red-bg:      rgba(220,38,38,.1);
  --gold:        #b45309;
  --cyan:        #0369a1;
  --orange:      #c2410c;
  --text:        #111827;
  --text-muted:  #374151;
  --text-dim:    #6b7280;
  --shadow:      0 4px 24px rgba(0,0,0,.1);
}
html[data-theme="light"] header              { background: rgba(244,245,249,.95); }
html[data-theme="light"] .hero               { background: linear-gradient(135deg, #f0edff 0%, #ebe5ff 60%, #eaf5f0 100%); }
html[data-theme="light"] .hero::before       { background: radial-gradient(circle, rgba(109,40,217,.08) 0%, transparent 70%); }
html[data-theme="light"] .landing-hero       { background: linear-gradient(180deg, rgba(109,40,217,.05) 0%, transparent 100%); }
html[data-theme="light"] .landing-bottom-cta { background: linear-gradient(135deg, rgba(109,40,217,.06), rgba(5,150,105,.03)); }
html[data-theme="light"] .skeleton           { background: linear-gradient(90deg, #eef0f6 25%, #e4e7f0 50%, #eef0f6 75%); background-size: 200% 100%; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Tillgänglighet: tydlig fokusring för tangentbordsnavigering ── */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
  outline: none;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #c4b5fd; }

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12,12,15,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(167,139,250,.5));
}

.logo h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.logo p {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .5px;
  text-transform: uppercase;
}

nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

#authNav {
  display: contents;
}

nav a {
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
}

nav a:hover {
  color: var(--text);
  background: var(--bg-card);
}

nav a.active {
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── Tema-toggle-knapp ─────────────────────────────────────────── */
.theme-toggle {
  flex-shrink: 0;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  padding: 5px 10px;
  line-height: 1;
  color: var(--text-muted);
  transition: border-color .2s, background .2s;
  margin-left: 6px;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent);
}

/* ── Stats Bar ──────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 28px 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
  transition: border-color .2s;
}

.stat-card:hover { border-color: var(--border-hover); }

.stat-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -1px;
}

.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }

.stat-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Content Grid ───────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
  margin-bottom: 60px;
}

/* ── Feed ───────────────────────────────────────────────────── */
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.feed-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
}

.feed-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
}

.filter-btn:hover, .filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

#feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Post Card ──────────────────────────────────────────────── */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: border-color .2s, transform .15s;
  cursor: pointer;
}

.post-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.post-card.expanded { cursor: default; }

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
}

.badge-allmänt    { background: rgba(112,112,160,.15); color: #9090c0; border: 1px solid rgba(112,112,160,.25); }
.badge-invägning  { background: rgba(34,211,238,.1);   color: var(--cyan);   border: 1px solid rgba(34,211,238,.25); }
.badge-humör      { background: rgba(167,139,250,.1);  color: var(--accent); border: 1px solid rgba(167,139,250,.25); }
.badge-biverkningar { background: rgba(251,146,60,.1); color: var(--orange); border: 1px solid rgba(251,146,60,.25); }
.badge-milestone  { background: rgba(251,191,36,.1);   color: var(--gold);   border: 1px solid rgba(251,191,36,.25); }
.badge-kost       { background: rgba(52,211,153,.1);   color: var(--green);  border: 1px solid rgba(52,211,153,.25); }

.post-date {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: auto;
}

.post-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.post-content {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.post-content.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.read-more {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

/* ── Weight Card ────────────────────────────────────────────── */
.weight-card {
  background: var(--bg-card);
  border: 1px solid rgba(34,211,238,.2);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.weight-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.weight-main { flex: 1; }

.weight-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: -1.5px;
  line-height: 1;
}

.weight-value .weight-kg {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

.weight-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 20px;
}

.weight-change.down { color: var(--green); background: var(--green-bg); }
.weight-change.up   { color: var(--red);   background: var(--red-bg); }
.weight-change.same { color: var(--text-muted); background: rgba(112,112,160,.1); }

.weight-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.measures-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.measure-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}

.measure-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.measure-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.measure-unit {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.measure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.weight-date {
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
  flex-shrink: 0;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.sidebar-card h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.chart-container { position: relative; height: 200px; }

.weight-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.weight-list::-webkit-scrollbar { width: 4px; }
.weight-list::-webkit-scrollbar-track { background: transparent; }
.weight-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.weight-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 13px;
}

.weight-list-item .wli-weight {
  font-weight: 600;
  color: var(--cyan);
}

.weight-list-item .wli-date {
  color: var(--text-dim);
  font-size: 11px;
}

/* ── Injection tracker ──────────────────────────────────────── */
.injection-info { display: flex; flex-direction: column; gap: 8px; }

.injection-dose {
  font-size: 13px;
  color: var(--text-muted);
}

.injection-alert {
  font-size: 15px;
  font-weight: 700;
  color: var(--red);
}

.injection-soon {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
}

.injection-ok {
  font-size: 15px;
  color: var(--text);
}

.injection-next {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Next milestone ──────────────────────────────────────────── */
.next-milestone-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

/* ── Health benefits ─────────────────────────────────────────── */
.health-list { display: flex; flex-direction: column; gap: 8px; }

.health-item {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  line-height: 1.4;
}

.health-item.achieved {
  background: rgba(52, 211, 153, .08);
  border: 1px solid rgba(52, 211, 153, .2);
  color: var(--green);
}

.health-item.upcoming {
  background: rgba(112, 112, 160, .06);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ── Step stats ─────────────────────────────────────────────── */
.steps-stats { display: flex; flex-direction: column; gap: 10px; }

.step-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.step-stat-row:last-child { border-bottom: none; }

.stat-sub { font-size: 13px; color: var(--text); margin-top: 3px; font-weight: 500; }

.step-stat-label { font-size: 13px; color: var(--text-muted); }
.step-stat-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.step-stat-value { font-size: 14px; font-weight: 700; color: var(--green); }
.step-stat-kcal  { font-size: 11px; color: var(--gold); }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

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

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

/* ── Footer ─────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ── Hero ───────────────────────────────────────────────────── */
.hero {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 36px 32px;
  background: linear-gradient(135deg, #13131a 0%, #1a1228 60%, #0f1a20 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 24px 0;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(124,58,237,.15) 0%, transparent 70%);
  pointer-events: none;
}

.hero-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.hero-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-dark);
  box-shadow: 0 0 0 6px rgba(124,58,237,.15), var(--shadow);
}

.hero-avatar-fallback {
  display: none;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 3px solid var(--accent-dark);
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.hero-content { flex: 1; min-width: 0; }

.hero-name {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text);
  margin-bottom: 6px;
}

.hero-bio {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 14px;
}

.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; }

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-glow);
  border: 1px solid rgba(167,139,250,.25);
  color: var(--accent);
}

/* ── Timeline ───────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent-dark), transparent);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -27px;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transition: transform .2s;
}

.timeline-dot.weight {
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34,211,238,.15);
}

.timeline-dot.milestone {
  background: var(--gold);
  width: 16px;
  height: 16px;
  left: -29px;
  top: 16px;
  box-shadow: 0 0 0 4px rgba(251,191,36,.2), 0 0 12px rgba(251,191,36,.4);
}

.timeline-item:hover .timeline-dot { transform: scale(1.3); }

/* ── Milestone card ─────────────────────────────────────────── */
.milestone-card {
  background: linear-gradient(135deg, rgba(251,191,36,.08), rgba(251,191,36,.03));
  border: 1px solid rgba(251,191,36,.25);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.milestone-icon { font-size: 36px; flex-shrink: 0; }

.milestone-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--gold);
  margin-bottom: 4px;
  font-weight: 600;
}

.milestone-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

/* ── Goal bar ───────────────────────────────────────────────── */
.goal-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
}

.goal-arrow { color: var(--text-dim); }
.goal-target { color: var(--green); }

.progress-track {
  background: var(--bg-input);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--green));
  border-radius: 20px;
  transition: width 1s cubic-bezier(.4,0,.2,1);
}

.goal-remaining {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: right;
}

/* ── BMI ────────────────────────────────────────────────────── */
.bmi-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.bmi-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text);
}

.bmi-label {
  font-size: 13px;
  font-weight: 600;
}

.bmi-track {
  position: relative;
  height: 8px;
  border-radius: 20px;
  background: linear-gradient(90deg, #60a5fa 0%, #34d399 30%, #fbbf24 60%, #f87171 100%);
  margin-bottom: 6px;
}

.bmi-needle {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
  transform: translateX(-50%);
  transition: left 1s cubic-bezier(.4,0,.2,1);
}

.bmi-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Admin Styles ───────────────────────────────────────────── */
.admin-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card .logo-icon { font-size: 48px; display: block; margin-bottom: 16px; }
.login-card h2 { font-size: 20px; margin-bottom: 6px; }
.login-card p  { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.admin-layout { display: none; }
.admin-layout.visible { display: block; }

.admin-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.admin-header h1 { font-size: 18px; font-weight: 700; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  transition: all .2s;
}

.tab-btn.active {
  background: var(--accent-dark);
  color: #fff;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

textarea { resize: vertical; min-height: 140px; }

select option { background: var(--bg-card); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s;
  letter-spacing: .01em;
}

.btn-primary {
  background: var(--accent-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124,58,237,.3);
}

.btn-primary:hover {
  background: #6d28d9;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(124,58,237,.45);
}

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

.btn-secondary:hover { border-color: var(--border-hover); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(248,113,113,.3);
  padding: 6px 12px;
  font-size: 12px;
}

.btn-danger:hover { background: var(--red-bg); }

.btn-full { width: 100%; justify-content: center; }

/* ── Admin lists ────────────────────────────────────────────── */
.admin-list { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

.admin-list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-list-item .item-info { flex: 1; min-width: 0; }
.admin-list-item .item-title { font-size: 14px; font-weight: 600; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.admin-list-item .item-meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--red-bg);
  border-radius: 6px;
  display: none;
}

.success-msg {
  color: var(--green);
  font-size: 13px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--green-bg);
  border-radius: 6px;
  display: none;
}

/* ══════════════════════════════════════════════════════════════
   MOBIL – primär design (sidan används mest i mobilen)
   ══════════════════════════════════════════════════════════════ */

/* Förhindra iOS-textstorleksjustering */
html { -webkit-text-size-adjust: 100%; }

/* ── Mobil (≤ 768px) ─────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Behållare */
  .container { padding: 0 14px; }

  /* ── Header: en rad, ej stackad ── */
  header { padding: 0; }
  header .container {
    flex-direction: row;
    align-items: center;
    gap: 0;
    padding: 10px 14px;
    min-height: 54px;
  }

  /* Logo: minimerad */
  .logo        { flex-shrink: 0; gap: 6px; }
  .logo-icon   { font-size: 22px; }

  /* Tema-knapp: kompakt på mobil */
  .theme-toggle { font-size: 14px; padding: 5px 8px; margin-left: 4px; }
  .logo h1     { display: none; }
  .logo p      { display: none; }

  /* Nav: horisontell scrollstrip – inga brutna rader */
  nav {
    flex: 1;
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-left: 4px;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a {
    white-space: nowrap;
    font-size: 12px;
    padding: 8px 10px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
  }

  /* ── KRITISKT: 16px i inputs förhindrar iOS-zoom ── */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
    padding: 12px 14px;
  }

  /* ── Touch-targets: min 44px höjd ── */
  .btn {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 15px;
  }
  .btn-full,
  .tab-panel .btn-primary { width: 100%; justify-content: center; }

  .filter-btn { min-height: 34px; padding: 6px 14px; }

  /* ── Layoutgrid: 1 kolumn ── */
  .content-grid { grid-template-columns: 1fr; }
  .sidebar      { position: static; }

  /* ── Stats-bar: 2 kolumner ── */
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 16px 0;
  }
  .stat-card  { padding: 14px 12px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 10px; }

  /* ── Hero ── */
  .hero {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
    gap: 16px;
  }
  .hero-tags                          { justify-content: center; }
  .hero-avatar, .hero-avatar-fallback { width: 72px; height: 72px; font-size: 28px; }
  .hero-name                          { font-size: 20px; }
  .hero-bio                           { font-size: 13px; }

  /* ── Feed ── */
  .feed-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .feed-filters::-webkit-scrollbar { display: none; }
  .feed-header { flex-wrap: wrap; gap: 8px; }

  /* ── Inläggskort ── */
  .post-card  { padding: 14px 16px; }
  .post-title { font-size: 15px; }

  /* ── Viktkort ── */
  .weight-card  { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  .weight-value { font-size: 26px; }

  /* ── Dashboard-/admin-flikar ── */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    white-space: nowrap;
    font-size: 13px;
    padding: 10px 14px;
    min-height: 42px;
  }

  /* ── Mätgrid ── */
  .measure-grid { grid-template-columns: repeat(2, 1fr); }

  /* ── Sidebar-kort ── */
  .sidebar-card { padding: 16px; }

  /* ── Login-kort ── */
  .login-card { padding: 28px 16px; margin: 16px; }

  /* ── Admin ── */
  .admin-container { padding: 0 14px 60px; }
  .admin-header    { flex-wrap: wrap; gap: 12px; }
}

/* ── Väldigt liten skärm (≤ 420px) ─────────────────────────── */
@media (max-width: 420px) {
  .stats-bar  { gap: 6px; }
  .stat-value { font-size: 20px; }
  .stat-card  { padding: 12px 10px; }

  .measure-grid { grid-template-columns: 1fr; }

  .hero-name   { font-size: 18px; }
  .post-title  { font-size: 14px; }

  nav a        { font-size: 11px; padding: 7px 8px; }

  .milestone-card { flex-direction: column; gap: 8px; }
  .milestone-icon { font-size: 28px; }
}
