/******************************
 *  Design-System & Basis
 ******************************/

/* Design Tokens */
:root {
  --page-max: 780px;
  /* max. Inhaltsbreite */

  /* Safe Area Insets (iOS Notch & Home Bar) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --nav-safe: var(--safe-bottom);

  /* Radien */
  --radius-xl: 20px;
  --radius: 14px;

  /* Brand Colors (beide Themes) */
  --brand: #2E7358;
  --danger: #D9534F;
  --ok: #4CAF50;
  --grad-1: #2E7358;
  --grad-2: #A2D8B8;

  /* Aliase */
  --primary: var(--brand);
}

/* Dark Theme (Default) */
:root,
[data-theme="dark"] {
  /* Farben - DARK MODE */
  --bg: #1a1d1c;
  --surface: #242827;
  --surface-2: #2a2e2d;
  --text: #ecf2ef;
  --muted: #9a9e9c;

  /* Symptom-Badges */
  --sym-yellow: #f0b860;
  --sym-yellow-text: #fff7e0;

  /* Schatten */
  --shadow: 0 10px 24px rgba(0, 0, 0, .35);
  --border-subtle: rgba(255, 255, 255, .12);

  /* Aliase */
  --card-bg: var(--surface);
  --app-bg: var(--bg);
  --text-muted: var(--muted);

  /* Color Scheme */
  color-scheme: dark;
}

/* Light Theme (moderne Food-App Ästhetik) */
[data-theme="light"] {
  /* Farben - LIGHT MODE */
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F8F8F8;
  --text: #1A1A1A;
  --muted: #6B6B6B;

  /* Symptom-Badges (beibehalten für Konsistenz) */
  --sym-yellow: #f0b860;
  --sym-yellow-text: #fff7e0;

  /* Schatten - sehr subtil für moderne Food-App Optik */
  --shadow: 0 2px 8px rgba(0, 0, 0, .06);
  --border-subtle: rgba(0, 0, 0, .06);

  /* Aliase */
  --card-bg: var(--surface);
  --app-bg: var(--bg);
  --text-muted: var(--muted);

  /* Color Scheme */
  color-scheme: light;
}

/* Fallback für Browser ohne data-theme Support */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1a1d1c;
    --surface: #242827;
    --surface-2: #2a2e2d;
    --text: #ecf2ef;
    --muted: #9a9e9c;
    --shadow: 0 10px 24px rgba(0, 0, 0, .35);
    --border-subtle: rgba(255, 255, 255, .12);
    --sym-yellow: #f0b860;
    --sym-yellow-text: #fff7e0;
    color-scheme: dark;
  }
}

/* Globales Box-Sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell,
    Noto Sans, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;

  /* Safe area padding für iOS mit Notch */
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);

  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}


/* Zusätzlicher Top-Abstand nur in der nativen iOS-App (WKWebView) */
.ml-ios-webview body {
  padding-top: max(16px, var(--safe-top));
}
.ml-ios-webview .nav {
  padding-bottom: max(var(--nav-safe, env(safe-area-inset-bottom, 0px)), 24px) !important;
}


img {
  max-width: 100%;
  height: auto;
  display: block;
}

/******************************
 *  Layout / App-Frame
 ******************************/

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 0; /* Wichtig für Flexbox */
}

/* Gemeinsamer Container */
.container,
.page-wrap {
  max-width: var(--page-max);
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}

/* Header */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.bar {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: .9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Wenn .bar innerhalb von .container ist, keine zusätzliche max-width nötig */
/* ABER: Behalte padding bei, damit Header korrekt aussieht */
.container > header > .bar {
  max-width: none;
  margin: 0;
  padding: .9rem 0;
}

/* Einheitliche Header-Positionierung für alle Seiten - Safe-Area wird über body padding-top behandelt */


.brand {
  font-weight: 700;
  letter-spacing: .2px;
}

/* Main-Content */
main {
  flex: 1;
  display: block;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: calc(76px + var(--nav-safe) + 12px);
  width: 100%;
  box-sizing: border-box;
}

/* Wenn main innerhalb von .container ist, kein zusätzliches Padding nötig (Container hat bereits padding: 16px) */
/* WICHTIG: max-width und margin beibehalten, damit main die volle Container-Breite nutzt */
.container > main {
  flex: 1;
  display: block;
  max-width: 100%;
  margin: 0;
  padding: 0;
  padding-bottom: calc(76px + var(--nav-safe) + 12px);
  width: 100%;
  box-sizing: border-box;
}

/* Profil-Seite: etwas schmaler, damit Formulare ruhiger wirken */
body.profile-page main {
  max-width: 680px;
}

/******************************
 *  Cards, Listen, Typo
 ******************************/

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-subtle);
  padding: 12px;
}

.section-title {
  margin: 1rem 0 .6rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.meta,
.time {
  font-size: .9rem;
  color: var(--muted);
}

/* Listen-Layout (Meals, Verlauf, Profilbereiche) */
.list {
  display: grid;
  gap: .6rem;
  padding: 0 !important;
  margin: 0 !important;
}

/******************************
 *  Meal Cards (Index & History)
 ******************************/

.item {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 48px 1fr 16px;
  gap: .5rem;
  padding: .35rem .6rem;
  align-items: center;
  border: 1px solid var(--border-subtle);
}

.thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  /* Optimierungen für schnelleres Laden */
  content-visibility: auto;
  will-change: contents;
  /* Verhindert Layout-Shift während des Ladens */
  aspect-ratio: 1;
}

.item .title {
  font-weight: 700;
  margin: 0;
  font-size: .94rem;
}

.item .time {
  font-size: .8rem;
  color: var(--muted);
  margin: .1rem 0 .25rem;
}

.item .desc {
  color: var(--muted);
  margin: .2rem 0 .35rem;
  line-height: 1.3;
}

.item .actions {
  margin-top: .2rem;
}

.item .actions .btn {
  display: inline-block;
  position: relative;
  z-index: 2;
}

@media (min-width: 700px) {
  .item {
    grid-template-columns: 60px 1fr auto;
  }

  .thumb {
    width: 60px;
    height: 60px;
  }
}

/* Chips rechts in Meal-Karte */
.chips {
  justify-self: end;
  align-self: center;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 32vw;
  pointer-events: none;
}

.chip {
  pointer-events: auto;
  padding: .26rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text);
}

.chip.ok {
  background: color-mix(in srgb, var(--ok) 18%, #fff);
  border-color: color-mix(in srgb, var(--ok) 40%, #fff);
  color: #0f1115;
}

.chip.sym {
  background: color-mix(in srgb, #f59e0b 18%, #fff);
  border-color: color-mix(in srgb, #f59e0b 40%, #fff);
  color: #0f1115;
}

@media (min-width: 700px) {
  .chips {
    max-width: 260px;
  }
}

/* Kompaktere Karten NUR auf Start/Verlauf – NICHT im Profil */
/* Dunkles Design: Rundes Bild-Layout (wie helles Design) */
body:not(.profile-page) main .list article.item {
  display: block !important;
  position: relative !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
  border: 1px solid var(--border-subtle) !important;
  background: var(--surface) !important;
  min-height: auto !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

body:not(.profile-page) main .list article.item > div:first-of-type {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

body:not(.profile-page) main .list article.item .thumb {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: 90px !important;
  height: 90px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  margin-left: 6px !important; /* Leichter Versatz nach rechts im dunklen Layout */
}

/* Analyse-Box und Feel-Buttons nehmen volle Breite unterhalb des Bildes ein */
body:not(.profile-page) main .list article.item .analysis-box {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  margin-top: 1rem !important;
}

body:not(.profile-page) main .list article.item .feelrow {
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  margin-top: 1rem !important;
}

body:not(.profile-page) main .list article.item .title {
  margin: 0 0 0.25rem 0 !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
}

body:not(.profile-page) main .list article.item .time {
  margin: 0 0 0.5rem 0 !important;
  font-size: 0.8rem !important;
  line-height: 1.2 !important;
  color: var(--muted) !important;
}

body:not(.profile-page) main .list article.item .feedback {
  margin-top: 0.25rem !important;
  font-size: 0.75rem !important;
}

body:not(.profile-page) main .list article.item .feelrow {
  gap: 0.5rem !important;
  display: flex !important;
}

body:not(.profile-page) main .list article.item .feel-btn {
  padding: 0.4rem 0.75rem !important;
  font-size: 0.8rem !important;
  border-radius: 20px !important;
}

/* Helles Design: Kacheln ohne Border mit rundem Bild - inspiriert von modernen Food-Apps */
[data-theme="light"] body:not(.profile-page) main .list article.item {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item > div:first-of-type {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .thumb {
  grid-column: 1 !important;
  grid-row: 1 !important;
  width: 90px !important;
  height: 90px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

/* Analyse-Box und Feel-Buttons nehmen volle Breite unterhalb des Bildes ein */
[data-theme="light"] body:not(.profile-page) main .list article.item .analysis-box {
  grid-column: 1 / -1 !important;
  grid-row: 2 !important;
  margin-top: 1rem !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .feelrow {
  grid-column: 1 / -1 !important;
  grid-row: 3 !important;
  margin-top: 1rem !important;
}

/* Typografie im hellen Design - moderner und luftiger */
[data-theme="light"] body:not(.profile-page) main .list article.item .title {
  font-size: 1rem !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  margin: 0 0 0.25rem 0 !important;
  color: var(--text) !important;
  letter-spacing: -0.01em !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .time {
  font-size: 0.8rem !important;
  margin: 0 0 0.5rem 0 !important;
  line-height: 1.2 !important;
  color: var(--muted) !important;
  font-weight: 400 !important;
}

/* Feedback-Status subtiler */
[data-theme="light"] body:not(.profile-page) main .list article.item .feedback {
  margin-top: 0.25rem !important;
  font-size: 0.75rem !important;
  color: var(--muted) !important;
  opacity: 0.8 !important;
}

/* Analysis-Box moderner - wie Badge/Chip */
[data-theme="light"] body:not(.profile-page) main .list article.item .analysis-box {
  margin-top: 0.5rem !important;
  padding: 0.5rem 0.75rem !important;
  border-radius: 12px !important;
  font-size: 0.8rem !important;
  line-height: 1.4 !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .analysis-box summary {
  font-weight: 600 !important;
  font-size: 0.8rem !important;
}

/* Feel-Buttons moderner - subtiler und luftiger */
[data-theme="light"] body:not(.profile-page) main .list article.item .feelrow {
  margin-top: 0.75rem !important;
  gap: 0.5rem !important;
  display: flex !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .feel-btn {
  padding: 0.4rem 0.75rem !important;
  font-size: 0.8rem !important;
  border-radius: 20px !important;
  font-weight: 500 !important;
  border: 1px solid var(--border-subtle) !important;
  background: var(--surface) !important;
  transition: all 0.2s ease !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .feel-btn:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .feel-btn.active {
  background: var(--brand) !important;
  color: white !important;
  border-color: var(--brand) !important;
  box-shadow: 0 2px 8px rgba(46, 115, 88, 0.25) !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .feel-btn--bad.active {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  box-shadow: 0 2px 8px rgba(217, 83, 79, 0.25) !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .feel-btn.inactive {
  opacity: 0.5 !important;
  background: var(--surface-2) !important;
  color: var(--muted) !important;
}

/* Chevron entfernen im hellen Design */
[data-theme="light"] body:not(.profile-page) main .list article.item .chev {
  display: none !important;
}

/* Delete-Button subtiler */
[data-theme="light"] body:not(.profile-page) main .list article.item .del-btn {
  background: rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  opacity: 0.8 !important;
  transition: opacity 0.2s ease !important;
}

[data-theme="light"] body:not(.profile-page) main .list article.item .del-btn:hover {
  opacity: 1 !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Analysis-Status-Chip moderner */
[data-theme="light"] body:not(.profile-page) main .list article.item .analysis-status-chip {
  border-radius: 12px !important;
  padding: 0.25rem 0.5rem !important;
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

/* Harmonischer auslaufender Schatten für alle Bilder */
[data-theme="light"] body:not(.profile-page) main .list article.item .thumb.thumb-border-safe,
[data-theme="light"] body.home-page main .list .item .thumb.thumb-border-safe,
[data-theme="light"] body:not(.profile-page) main .list article.item .thumb.thumb-border-caution,
[data-theme="light"] body.home-page main .list .item .thumb.thumb-border-caution,
[data-theme="light"] body:not(.profile-page) main .list article.item .thumb.thumb-border-unsafe,
[data-theme="light"] body.home-page main .list .item .thumb.thumb-border-unsafe {
  border: none !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

/* Helles Design für History-Seite (body.home-page) - inspiriert von modernen Food-Apps */
[data-theme="light"] body.home-page main .list .item {
  border: none !important;
  border-left: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

[data-theme="light"] body.home-page main .list .item .thumb {
  width: 90px !important;
  height: 90px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
}

/* Typografie im hellen Design für History - moderner und luftiger */
[data-theme="light"] body.home-page main .list .item .title {
  font-size: 1rem !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  margin: 0 0 0.25rem 0 !important;
  color: var(--text) !important;
  letter-spacing: -0.01em !important;
}

[data-theme="light"] body.home-page main .list .item .time {
  font-size: 0.8rem !important;
  margin: 0 0 0.5rem 0 !important;
  line-height: 1.2 !important;
  color: var(--muted) !important;
  font-weight: 400 !important;
}

[data-theme="light"] body.home-page main .list .item .desc {
  font-size: 0.8rem !important;
  margin: 0.25rem 0 !important;
  line-height: 1.4 !important;
  color: var(--muted) !important;
}

/* Analysis-Box moderner für History */
[data-theme="light"] body.home-page main .list .item .analysis-box {
  margin-top: 0.5rem !important;
  padding: 0.5rem 0.75rem !important;
  border-radius: 12px !important;
  font-size: 0.8rem !important;
  line-height: 1.4 !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] body.home-page main .list .item .analysis-box details summary {
  font-weight: 600 !important;
  font-size: 0.8rem !important;
}

/* Status-Chips moderner */
[data-theme="light"] body.home-page main .list .item .chip {
  border-radius: 12px !important;
  font-size: 0.7rem !important;
  padding: 0.25rem 0.5rem !important;
  border: none !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
}

/* Delete-Button subtiler für History */
[data-theme="light"] body.home-page main .list .item .del-btn {
  background: rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
  opacity: 0.8 !important;
  transition: opacity 0.2s ease !important;
}

[data-theme="light"] body.home-page main .list .item .del-btn:hover {
  opacity: 1 !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Status-Chips Positionierung anpassen für runde Bilder */
[data-theme="light"] body.home-page main .list .item .status-chips {
  top: 70px !important;
}

/* Primary Button moderner für History */
[data-theme="light"] body.home-page main .list .item .btn-primary {
  border-radius: 20px !important;
  font-weight: 500 !important;
  border: 1px solid var(--border-subtle) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] body.home-page main .list .item .btn-primary:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
  background: var(--brand) !important;
  color: white !important;
  border-color: var(--brand) !important;
}

/* Pfeil rechts optional entfernen */
body:not(.profile-page) main .list article.item .chev {
  display: none !important;
}

/* Abstand zwischen Karten auf Feed enger */
body:not(.profile-page) main .list {
  gap: .45rem !important;
  padding: 0 !important;
  margin: 0 !important;
}

/******************************
 *  Bottom Navigation (PWA)
 ******************************/

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding-bottom: max(var(--nav-safe, env(safe-area-inset-bottom, 0px)), 16px);
  background: var(--surface);
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -6px 18px rgba(16, 20, 24, .06);
}

.tabs {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: .4rem .8rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .4rem;
}

.tab {
  appearance: none;
  background: transparent;
  border: 0;
  padding: .5rem .25rem .6rem;
  display: grid;
  place-items: center;
  gap: .2rem;
  text-decoration: none;
  color: inherit;
  font-size: .78rem;
}

.tab svg {
  width: 22px;
  height: 22px;
}

.tab.active {
  color: var(--brand);
  font-weight: 700;
}

/******************************
 *  Hero Upload
 ******************************/

.hero {
  background: var(--brand);
  border-radius: var(--radius-xl);
  padding: 1.1rem;
  color: #fff;
  box-shadow: var(--shadow);
  display: grid;
  gap: .5rem;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.hero input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 5;
}

.hero .h {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
}

.hero .sub {
  opacity: .95;
  font-size: .95rem;
}

/******************************
 *  Buttons
 ******************************/

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: 10px 12px;
  min-height: 44px;
  /* PWA: Touch-Ziel */
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .04s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
}

.btn:hover {
  filter: brightness(.98);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn.icon {
  width: 40px;
  height: 40px;
  padding: 0;
}

.btn-primary,
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Gradient-CTA (Premium etc.) */
.btn-gradient {
  position: static;
  display: inline-flex;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow, 0 8px 24px rgba(16, 20, 24, .12));
  background: linear-gradient(90deg, var(--grad-1, #7c3aed), var(--grad-2, #fb923c));
  color: #fff;
  border: 0;
}

/* Sticky Savebar (optional) */
.savebar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), var(--bg));
  padding: 12px;
}

.save {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
}

/******************************
 *  Inputs & Form-Layout
 ******************************/

/* Basis-Inputs */
input[type=text],
input[type=email],
input[type=password],
input[type=search],
textarea,
select {
  width: 100%;
  background: #2a2e2d !important;
  border-radius: 12px;
  padding: .8rem;
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: .95rem;
  font-family: inherit;
  color: #ecf2ef !important;
  -webkit-text-fill-color: #ecf2ef !important;
  /* Re-enable text selection for inputs */
  -webkit-user-select: text;
  user-select: text;
  /* Prevent iOS zoom on focus */
  font-size: 16px;
}

/* Override autofill styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #2a2e2d inset !important;
  -webkit-text-fill-color: #ecf2ef !important;
  color: #ecf2ef !important;
}

textarea {
  min-height: 90px;
  resize: vertical;
  /* Re-enable text selection */
  -webkit-user-select: text;
  user-select: text;
  color: #ecf2ef !important;
  -webkit-text-fill-color: #ecf2ef !important;
  background: #2a2e2d !important;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: 2px;
}

/* Speziell für Elemente mit .input (Profilseite) */
.input,
select.input,
textarea.input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Grids */
.grid-2,
.grid-3 {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Checkbox-Stacks */
.stack label {
  display: block;
  margin-bottom: 6px;
}

/******************************
 *  Toggle Segments & Pills
 ******************************/

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.seg button {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  font-weight: 700;
  color: var(--muted);
  opacity: .9;
  transition: all .15s ease;
}

.seg button:hover {
  filter: brightness(0.97);
}

.seg button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  opacity: 1;
}

.seg button:active {
  transform: scale(0.97);
}

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

.pill {
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.pill.active {
  background: color-mix(in srgb, var(--brand) 18%, #fff);
  border-color: color-mix(in srgb, var(--brand) 40%, #fff);
  color: #0f1115;
}

/******************************
 *  Icon Buttons
 ******************************/

.iconbtn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.iconbtn svg {
  width: 22px;
  height: 22px;
  display: block;
}

/******************************
 *  Progress & Toast
 ******************************/

#progress {
  display: none;
  margin-top: 12px;
  height: 8px;
  background: #e6e8eb;
  border-radius: 8px;
}

#bar {
  width: 0%;
  height: 8px;
  background: var(--brand);
  border-radius: 8px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #111;
  color: #fff;
  padding: .55rem .8rem;
  border-radius: 8px;
  display: none;
  z-index: 9999;
}

/******************************
 *  Lightbox
 ******************************/

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 18px;
}

.lb-card {
  background: var(--surface);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .35);
  overflow-y: auto;
  max-height: 90vh;
}

.lb-media {
  width: 100%;
  display: block;
  max-height: 56vh;
  object-fit: contain;
  background: #000;
}

.lb-body {
  padding: 14px;
}

.lb-body .chips {
  justify-self: start;
  max-width: 100%;
  flex-wrap: wrap;
  margin-top: 8px;
}

@media (max-width: 640px) {
  #lightbox {
    padding: 10px;
  }

  .lb-card {
    max-height: 95vh;
  }

  .lb-media {
    max-height: 35vh;
  }

  .lb-body {
    padding: 12px;
  }

  .lb-body .chips {
    gap: 6px;
    flex-wrap: wrap;
  }

  .lb-body .chip {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
  }
}

/******************************
 *  Bottom Sheet
 ******************************/

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(76px + max(var(--nav-safe, env(safe-area-inset-bottom, 0px)), 20px) - 8px);
  transform: translateY(100%);
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .3);
  transition: transform .25s ease, opacity .25s ease, visibility .25s ease;
  z-index: 2000 !important;
  /* Direkt am oberen Footer-Rand - nahtloser Übergang, leicht überlappend */
  max-height: calc(80vh - 76px - max(var(--nav-safe, env(safe-area-inset-bottom, 0px)), 20px) + 8px);
  overflow-y: auto;
  /* Standardmäßig versteckt */
  visibility: hidden;
  opacity: 0;
}

.sheet.open {
  transform: translateY(0);
  visibility: visible;
  opacity: 1;
}

.sheet .grip {
  width: 48px;
  height: 5px;
  border-radius: 999px;
  background: #c9d1d9;
  margin: 10px auto;
}

.sheet .title {
  font-weight: 700;
  padding: 0 16px;
}

.sheet .options {
  display: grid;
  gap: 8px;
  padding: 10px 16px;
}

.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .7rem .9rem;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.opt input {
  accent-color: var(--brand);
}

.sheet .row {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
}

.sheet .row .btn {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: .75rem 1rem;
  font-weight: 700;
}

.btn-cancel,
.sheet .row .btn-cancel {
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border-subtle) !important;
}

.btn-save {
  background: var(--grad-1);
  color: #fff;
}

/******************************
 *  Feel-Buttons (Wohl / Unwohl)
 ******************************/

.feelrow {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.feel-btn {
  flex: 1;
  border: 0;
  border-radius: 8px;
  padding: .22rem .55rem;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: background-color .2s, color .2s, transform .15s, opacity .2s;
}

.feel-btn--well {
  background: color-mix(in srgb, var(--brand) 15%, #fff);
  color: color-mix(in srgb, var(--brand) 70%, #000);
}

.feel-btn--bad {
  background: color-mix(in srgb, var(--danger) 15%, #fff);
  color: color-mix(in srgb, var(--danger) 70%, #000);
}

.feel-btn.active {
  background: var(--brand);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .05);
  opacity: 1;
}

.feel-btn--bad.active {
  background: var(--danger);
  color: #fff;
}

.feel-btn.inactive {
  background: var(--surface-2) !important;
  color: var(--muted) !important;
  opacity: .6;
  filter: none;
}

.feel-btn:hover:not(.active) {
  filter: brightness(0.98);
}

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

/* Dark Theme Feel Buttons */
[data-theme="dark"] .feel-btn--well,
:root:not([data-theme]) .feel-btn--well {
  background: color-mix(in srgb, var(--brand) 25%, var(--surface-2));
  color: var(--ok);
}

[data-theme="dark"] .feel-btn--bad,
:root:not([data-theme]) .feel-btn--bad {
  background: color-mix(in srgb, var(--danger) 25%, var(--surface-2));
  color: var(--danger);
}

[data-theme="dark"] .feel-btn.inactive,
:root:not([data-theme]) .feel-btn.inactive {
  background: var(--surface-2) !important;
  color: var(--muted) !important;
  opacity: .55;
}

/* Light Theme Feel Buttons */
[data-theme="light"] .feel-btn--well {
  background: color-mix(in srgb, var(--brand) 15%, var(--surface));
  color: color-mix(in srgb, var(--brand) 70%, #000);
}

[data-theme="light"] .feel-btn--bad {
  background: color-mix(in srgb, var(--danger) 15%, var(--surface));
  color: color-mix(in srgb, var(--danger) 70%, #000);
}

/******************************
 *  Filter / Suche
 ******************************/

.filter-title {
  font-weight: 700;
  margin: 1rem 0 .4rem;
}

.filter-card {
  display: grid;
  gap: .8rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.filter-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}

@media (max-width: 520px) {
  .filter-grid-2 {
    grid-template-columns: 1fr;
  }
}

.filter-card select,
.filter-card input[type=search] {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--surface-2);
  padding: .45rem .8rem;
  font-size: 16px;
  /* iOS Zoom Prevention */
  line-height: 1.3;
  color: var(--text);
  font-family: inherit;
}

.filter-card select:focus,
.filter-card input[type=search]:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent);
  outline-offset: 2px;
}

.filter-card input::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.filter-card select {
  -webkit-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%),
    linear-gradient(to right, transparent, transparent);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 10px) 50%,
    100% 0;
  background-size: 6px 6px, 6px 6px, 2.5rem 100%;
  background-repeat: no-repeat;
  padding-right: 2.2rem;
}

/******************************
 *  Auth / Gate (Login/Register)
 ******************************/

body.gate {
  background: var(--app-bg);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  width: 100%;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

.gate .container {
  max-width: 520px;
  margin: 0 auto;
  padding: 1.2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-subtle);
  padding: 1rem;
}

.auth-title {
  margin: .2rem 0 .6rem;
  font-weight: 800;
  letter-spacing: .2px;
}

.auth-sub {
  color: var(--text-muted);
  margin: 0 0 1rem;
  font-size: .95rem;
}

.auth-tabs {
  display: flex;
  gap: .5rem;
  margin: .2rem 0 1rem;
}

.auth-tab {
  appearance: none;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: inherit;
  padding: .5rem .8rem;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab[aria-selected="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-row {
  margin: .7rem 0;
}

.form-row label {
  display: block;
  font-weight: 700;
  margin: 0 0 .25rem;
  font-size: .9rem;
}

.form-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn-link {
  background: transparent;
  border: 0;
  color: var(--brand);
  font-weight: 700;
  padding: .4rem .2rem;
  cursor: pointer;
}

/* Alerts */
.alert {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: .65rem .8rem;
  margin: .6rem 0;
}

.alert.error {
  background: color-mix(in srgb, var(--danger) 12%, #fff);
}

.alert.success {
  background: color-mix(in srgb, var(--ok) 12%, #fff);
}

.alert .strong {
  font-weight: 800;
}

/******************************
 *  Profil-Seite
 ******************************/

/* Labels & Inputs im Profil */
.list .item label>span {
  display: block;
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: .4rem;
}

.list .item .input,
.list .item textarea,
.list .item select {
  width: 100%;
  min-height: 44px;
  /* Better touch target */
  font-size: 16px;
  /* iOS Zoom Prevention */
}

/* Profil: Item-Karten nicht wie Meal-Karten layouten */
body.profile-page .list .item {
  display: block !important;
  padding: 16px;
  /* More breathing room */
  box-shadow: var(--shadow);
  background: var(--surface);
}

body.profile-page .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
  max-width: 100%;
}

body.profile-page .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  /* Larger touch target */
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

/* Checkbox in Chip */
.list .item .chip input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0;
  width: 18px;
  height: 18px;
}

.list .item textarea.input {
  min-height: 100px;
  resize: vertical;
}

/* Premium-Teaser */
.premium-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.premium-copy {
  flex: 1 1 280px;
  line-height: 1.45;
  color: var(--text);
}

.premium-points {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.premium-points li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0;
}

.premium-points li::before {
  content: "✓";
  flex: 0 0 auto;
  font-weight: 600;
  opacity: .8;
}

.premium-cta {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/******************************
 *  Analysis-Page
 ******************************/

.analysis-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 16px;
}

.analysis-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-subtle);
  padding: 16px;
}

.analysis-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 .6rem;
}

.analysis-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: .5rem 0;
}

.analysis-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  border: none;
  cursor: pointer;
  min-height: 44px;
}

.analysis-btn[disabled] {
  opacity: .6;
  cursor: not-allowed;
}

.analysis-hint {
  font-size: .85rem;
  color: var(--muted);
  margin-top: 8px;
}

.chart-wrap {
  width: 100%;
  max-width: 780px;
  margin: 0 auto var(--space-4, 20px);
}

.analysis-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Markdown-Ergebnis */
#userText {
  white-space: normal;
  line-height: 1.5;
  font-size: 1rem;
}

#userText h1,
#userText h2,
#userText h3,
#userText h4 {
  margin: .8rem 0 .4rem;
  line-height: 1.3;
}

#userText p {
  margin: .5rem 0;
}

#userText ul,
#userText ol {
  margin: .4rem 0 .6rem 1.2rem;
  padding-left: 1.2rem;
}

/******************************
 *  Traffic Light Component (Analysis)
 ******************************/

.traffic-light {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
}

.traffic-light-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid;
  transition: all 0.2s ease;
}

.traffic-light-item.safe {
  border-left-color: #4CAF50;
  background: rgba(76, 175, 80, 0.1);
}

.traffic-light-item.caution {
  border-left-color: #f0b860;
  background: rgba(240, 184, 96, 0.1);
}

.traffic-light-item.unsafe {
  border-left-color: #D9534F;
  background: rgba(217, 83, 79, 0.1);
}

.traffic-light-item.unknown {
  border-left-color: var(--muted);
  background: rgba(154, 158, 156, 0.1);
}

/* Light Theme Anpassungen für Traffic Light */
[data-theme="light"] .traffic-light-item {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .traffic-light-item.safe {
  background: rgba(76, 175, 80, 0.08);
}

[data-theme="light"] .traffic-light-item.caution {
  background: rgba(240, 184, 96, 0.08);
}

[data-theme="light"] .traffic-light-item.unsafe {
  background: rgba(217, 83, 79, 0.08);
}

[data-theme="light"] .traffic-light-item.unknown {
  background: rgba(0, 0, 0, 0.02);
}

.traffic-light-icon {
  font-size: 1.2em;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

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

.traffic-light-label {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
  color: var(--text);
}

.traffic-light-reason {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.traffic-light-item.safe .traffic-light-label {
  color: #4CAF50;
}

.traffic-light-item.caution .traffic-light-label {
  color: #f0b860;
}

.traffic-light-item.unsafe .traffic-light-label {
  color: #D9534F;
}

.traffic-light-item.unknown .traffic-light-label {
  color: var(--muted);
}

#userText li {
  margin: .2rem 0;
}

#userText>*:first-child {
  margin-top: 0;
}

#userText>*:last-child {
  margin-bottom: 0;
}

#userText .md-meta {
  font-size: .9rem;
  color: var(--muted);
  margin: 0 0 .5rem;
}

/******************************
 *  Empty-State Cards (Dark)
 ******************************/

.card.empty-state {
  position: relative;
  padding: 1.5rem;
  border-radius: 18px;
  background:
    radial-gradient(120% 140% at 10% -10%, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02) 60%),
    rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  text-align: center;
  color: #d8dbe0;
}

.empty-illus {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
  color: #d8dbe0;
  opacity: 0.9;
}

.empty-title {
  margin: 0.25rem 0 0.25rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: #ffffff;
}

.empty-text {
  margin: 0 0 0.75rem;
  line-height: 1.45;
  color: #c9cdd3;
}

/* Light Theme Anpassungen für Empty State */
[data-theme="light"] .card.empty-state {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow);
  color: var(--text);
}

[data-theme="light"] .empty-illus {
  color: var(--muted);
  opacity: 0.7;
}

[data-theme="light"] .empty-title {
  color: var(--text);
}

[data-theme="light"] .empty-text {
  color: var(--muted);
}

.empty-actions {
  display: flex;
  gap: .6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: .25rem 0 .25rem;
}

.empty-tips {
  list-style: none;
  margin: .75rem 0 0;
  padding: 0;
  display: grid;
  gap: .35rem;
}

.empty-tips li {
  display: inline-block;
  font-size: .9rem;
  color: #aeb4be;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: .5rem .75rem;
  border-radius: 999px;
}

/* Light Theme Anpassungen für Empty Tips */
[data-theme="light"] .empty-tips li {
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
}

@media (min-width: 480px) {
  .card.empty-state {
    padding: 1.75rem;
  }
}

/******************************
 *  Symptom-Badges (gelb/grün)
 ******************************/

.chip.sym {
  background: var(--sym-yellow) !important;
  color: var(--sym-yellow-text) !important;
  border: 1px solid rgba(16, 20, 24, .18);
  box-shadow: 0 0 4px rgba(0, 0, 0, .15), inset 0 -1px 0 rgba(0, 0, 0, .08);
  font-weight: 800;
  text-transform: uppercase;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  padding: 0 !important;
  line-height: 1;
  text-align: center;
  font-size: 13px;
  box-sizing: border-box;
  vertical-align: middle;

  margin-left: -10px;
}

.chip.ok {
  background: var(--ok) !important;
  color: #fff !important;
  border: 1px solid rgba(16, 20, 24, .18);
  box-shadow: 0 0 4px rgba(0, 0, 0, .15), inset 0 -1px 0 rgba(0, 0, 0, .08);
  font-weight: 800;
  text-transform: uppercase;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  padding: 0 !important;
  line-height: 1;
  text-align: center;
  font-size: 13px;
  box-sizing: border-box;
  vertical-align: middle;

  margin-left: -10px;
}

@media (max-width: 420px) {

  .chip.sym,
  .chip.ok {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 14px;
  }
}

@media (prefers-color-scheme: dark) {

  .chip.sym,
  .chip.ok {
    border-color: rgba(255, 255, 255, .12);
    box-shadow: 0 0 6px rgba(255, 255, 255, .08);
  }
}

/******************************
 *  Scanner-Viewport (Barcode)
 ******************************/

.scanner-viewport {
  width: 100%;
  height: 60vh;
  background: var(--surface-2, #f1f2f4);
  border-radius: var(--radius, 14px);
  overflow: hidden;
  position: relative;
}

/******************************
 *  Kleine Helpers
 ******************************/

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

/* Verhindere "Breitenkappen" in Sektionen */
.container .filter-card,
.container .list,
.container .card,
.container .section-title {
  max-width: none;
  width: 100%;
}

/* Sicherstellen, dass alle Elemente innerhalb von .container die volle Breite nutzen */
.container > * {
  width: 100%;
  max-width: 100%;
}

/* Mobile Tweaks */
@media (max-width: 380px) {

  .container,
  .page-wrap {
    padding: 12px;
  }

  .card {
    padding: 10px;
  }

  .item {
    gap: .4rem;
  }
}

/* Alerts / Flash Messages */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  border: 1px solid transparent;
}

.alert.success {
  background-color: rgba(46, 115, 88, 0.15);
  /* Brand Green transparent */
  color: #a2d8b8;
  /* Light Green text */
  border-color: rgba(46, 115, 88, 0.3);
}

.alert.error {
  background-color: rgba(217, 83, 79, 0.15);
  /* Red transparent */
  color: #dc2626;
  /* Dark Red text */
  border-color: rgba(217, 83, 79, 0.3);
}

.alert .strong {
  font-weight: 700;
  margin-right: 4px;
}

/* Einheitliche Safe-Area-Behandlung für alle Seiten */
/* Header-Positionierung wird über body padding-top (Zeile 95) und .ml-ios-webview body (Zeile 107) geregelt */
/* Keine seiten-spezifischen Header-Paddings mehr nötig - alle Seiten nutzen die gleiche Struktur */

/* Einheitliche Footer-Positionierung für alle Seiten */
/* Keine seiten-spezifischen Regeln mehr nötig - alle Seiten nutzen die gleiche Regel aus footer.php */

/* Analyse-Details Modal */
.analysis-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.analysis-modal:not(.hide) {
  opacity: 1;
  pointer-events: all;
}

.analysis-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] .analysis-modal-backdrop {
  background: rgba(255, 255, 255, 0.7);
}

.analysis-modal-content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  color: var(--text);
  border-radius: 20px;
  max-width: 600px;
  max-height: 85vh;
  width: 90%;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.analysis-modal:not(.hide) .analysis-modal-content {
  transform: scale(1);
}

.analysis-modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}

.analysis-modal-header strong {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.analysis-modal-header .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.analysis-modal-header .icon-btn:hover {
  background: var(--muted);
  color: var(--surface);
  transform: rotate(90deg);
}

.analysis-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  background: var(--surface);
  color: var(--text);
}

/* Traffic Light im Modal */
.analysis-modal-body .traffic-light {
  margin-bottom: 1.5rem;
}

.analysis-modal-body .traffic-light-item {
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

[data-theme="light"] .analysis-modal-body .traffic-light-item {
  background: var(--surface-2);
  border-color: var(--border-subtle);
}

.analysis-modal-body .traffic-light-item.safe {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.3);
}

.analysis-modal-body .traffic-light-item.caution {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
}

.analysis-modal-body .traffic-light-item.unsafe {
  background: rgba(244, 67, 54, 0.1);
  border-color: rgba(244, 67, 54, 0.3);
}

/* Vollständiger Analyse-Text im Modal */
.analysis-modal-body .full-analysis-text {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  line-height: 1.6;
  color: var(--text);
}

.analysis-modal-body .full-analysis-text p {
  margin-bottom: 1rem;
}

.analysis-modal-body .full-analysis-text p:last-child {
  margin-bottom: 0;
}

/* Responsive Anpassungen */
@media (max-width: 600px) {
  .analysis-modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 16px;
  }

  .analysis-modal-header {
    padding: 1rem 1.25rem;
  }

  .analysis-modal-body {
    padding: 1.25rem;
  }
}
