/* --- VARIABLEN & THEME --- */
:root {
  --bg-main: #333333;
  --bg-secondary: #444444;
  --primary-accent: #831b91;
  --accent-soft: rgba(131, 27, 145, 0.18);
  --text-main: #ffffff;
  --text-muted: #aaaaaa;
  --table-header-bg: #222222;
  --input-border: #555555;
  --row-even: #3d3d3d;
  --row-odd: #444444;
  --highlight-color: #fff8b3;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --shadow-color: rgba(0, 0, 0, 0.18);

  --protein-color: var(--primary-accent);
  --carbs-color: #6e6ce7;
  --fat-color: #e4a419;

  --page-max-width: 1200px;
  --page-side-padding: clamp(12px, 2vw, 24px);
  --control-min-height: 44px;
}

/* --- NOTEBOOK DESIGN (PAPIER-LOOK) --- */
body.theme-notebook {
  --bg-main: #efe3c9;
  --bg-secondary: #e6deac;
  --primary-accent: #8b5e3c;
  --accent-soft: rgba(139, 94, 60, 0.16);
  --text-main: #3b2a1f;
  --text-muted: #7a614f;
  --table-header-bg: #e7d4b3;
  --input-border: #b9996b;
  --row-even: #f4e6cf;
  --row-odd: #f3dec4;
  --highlight-color: #f5c96b;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-strong: rgba(255, 255, 255, 0.8);
  --shadow-color: rgba(80, 50, 20, 0.16);
}

/* --- STUDYTOOL MINI-BAR DESIGN --- */
.stats-mini-bar {
  display: inline-flex;
  flex-direction: column;
  gap: 12px;
  background-color: #222222;
  color: white;
  padding: 15px;
  margin: 15px 20px;
  border-radius: 8px;
  min-width: 250px;
  border: 1px solid #444;
}

.stats-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.counter-section {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.counter-value {
  font-size: 20px;
  font-weight: bold;
  color: var(--primary-accent);
}

.counter-label {
  font-size: 12px;
  color: #888;
}

.stats-mini-nav {
  display: flex;
  gap: 4px;
}

.mini-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 3px;
  height: 50px;
  margin-top: 10px;
  border-top: 1px solid #333;
  width: 100%;
  padding-top: 8px;
}

.page-careerplanning .career-disclaimer {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--input-border);
  color: var(--text-muted);
  font-size: 0.92rem;
}

.page-agb main {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}

.page-agb .legal-card {
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 8px 24px var(--shadow-color);
  display: grid;
  gap: 16px;
}

.page-agb .legal-section {
  background: var(--surface-strong);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 14px;
}

.page-agb .legal-section h2,
.page-agb .legal-section h3,
.page-agb .legal-card h1 {
  margin: 0 0 8px;
}

.page-agb .legal-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.page-agb .legal-note {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.mini-bar-wrapper {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
}

.mini-bar-value {
  font-size: 9px;
  font-weight: bold;
  color: var(--primary-accent);
  margin-bottom: 2px;
}

.mini-bar {
  width: 70%;
  background-color: var(--primary-accent);
  border-radius: 1px 1px 0 0;
  transition: height 0.4s ease-out;
  min-height: 2px;
}

* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: 'Segoe UI', Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
}

html {
  font-size: 16px;
}

/* --- TYPOGRAFIE --- */
h1, h2, h3, h4 {
  margin: 20px;
  color: var(--text-main);
}

/* --- NAVIGATION (NAVBAR) --- */
.navbar {
  background-color: #1a1a1a;
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 1000;
}

body.theme-notebook .navbar {
  background-color: #d9bf95;
  box-shadow: 0 2px 10px rgba(80, 50, 20, 0.16);
}

.nav-link {
  color: white;
  text-decoration: none;
  font-weight: bold;
  padding: 8px 12px;
  border-radius: 5px;
  transition: background 0.3s;
}

body.theme-notebook .nav-link { color: #422d1f; }

.nav-link:hover {
  background-color: #444;
}

.nav-link.active {
  background-color: var(--primary-accent);
  color: #fff;
}

.admin-link {
  display: none;
}

.admin-link.visible {
  display: inline-block;
  color: #ff5252;
  font-weight: bold;
  text-decoration: none;
  border: 1px solid #ff5252;
  padding: 5px 10px;
  border-radius: 4px;
}

/* --- SETTINGS BUTTON --- */
.settings-btn {
  margin-left: auto;
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-icon {
  width: 40px;
  height: 40px;
  display: block;
  border-radius: 10px;
}

.navbar-user-area {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.navbar-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  /* border-radius: 999px; */
  /* background: rgba(255, 255, 255, 0.08); */
  /* border: 1px solid rgba(255, 255, 255, 0.12); */
  color: var(--text-main);
  font-size: 0.9rem;
  white-space: nowrap;
}

/*
.navbar-user-chip::before {
  content: '•';
  color: var(--primary-accent);
  font-size: 1.1rem;
  line-height: 1;
}
  */

.navbar-user-area .settings-btn {
  margin-left: 0;
}

.settings-menu {
  position: absolute;
  right: 20px;
  top: calc(100% + 8px);
  display: none;
  z-index: 2000;
  max-height: min(82vh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.settings-menu.open {
  display: block;
}

.settings-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
  min-width: 260px;
  max-width: min(480px, calc(100vw - 24px));
  box-shadow: 0 10px 24px var(--shadow-color);
}

.settings-panel h4 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-main);
}

.settings-panel label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-main);
}

.settings-panel input[type="text"],
.settings-panel select,
.settings-panel input[type="color"] {
  width: 100%;
}

.settings-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--surface);
}

.settings-inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-terms-block {
  border: 1px solid var(--input-border);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.settings-terms-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-main);
}

.settings-terms-frame {
  width: 100%;
  min-height: 240px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: #fff;
}

/* --- ALLGEMEINE BUTTONS --- */
button, .btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background-color: #222;
  color: white;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.95rem;
  line-height: 1.2;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-min-height);
  touch-action: manipulation;
}

button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-accent);
  outline-offset: 2px;
}

button[type="submit"] {
  background-color: var(--primary-accent);
}

button:hover, .btn:hover {
  background-color: #555;
  transform: translateY(-1px);
}

button:active, .btn:active {
  transform: translateY(0);
}

.btn-klein {
  padding: 8px 12px;
  font-size: 0.9rem;
  min-height: 38px;
}

.btn-mini {
  background-color: #444;
  border: 1px solid #555;
  padding: 8px 10px;
  font-size: 0.82rem;
  min-height: 38px;
}

.btn-tasksH:hover { background-color: var(--highlight-color); color: black; }
.btn-tasksD:hover { background-color: #ff5252; color: white; }
.btn-tasksC:hover { background-color: var(--primary-accent); color: white; }

/* --- SIDEBAR DESIGN (Global Sync) --- */
@media screen and (min-width: 769px) {
    body.page-healthtool, body.page-careerplanning {
        display: grid;
    grid-template-columns: 240px 1fr;
        grid-template-rows: auto 1fr;
        grid-template-areas: 
            "main-nav main-nav"
            "side-nav content";
        min-height: 100vh;
    }

    .navbar { grid-area: main-nav; }
    .sub-navbar {
        grid-area: side-nav;
        background-color: #222 !important;
        padding-top: 30px;
        display: flex;
        flex-direction: column;
        border-right: 1px solid #333;
    }

    body.theme-notebook .sub-navbar {
        background-color: #e7d4b3 !important;
        border-right: 1px solid #b9996b;
    }

    .tab-section {
        grid-area: content;
        padding: 20px;
    }

    .sub-nav-link {
        background: none;
        color: #888;
        border: none;
        padding: 15px 20px;
        text-align: left;
        width: 100%;
        cursor: pointer;
        font-size: 16px;
        border-left: 4px solid transparent;
        transition: 0.2s;
    }

    body.theme-notebook .sub-nav-link { color: #7a614f; }

    .sub-nav-link.active {
        color: var(--primary-accent);
        border-left: 4px solid var(--primary-accent);
        background-color: #333;
    }

    body.theme-notebook .sub-nav-link.active {
        background-color: rgba(255, 255, 255, 0.3);
    }

    .sidebar-action-area {
        display: flex;
        justify-content: center;
        padding: 20px 0;
        width: 100%;
        margin-top: auto;
    }

    .centered-btn { width: 85%; }
}

/* --- CAREER / GRADES SPEZIFISCH (GLOW & TILES) --- */

/* Glow Notenkreise (Foto 2 & 3) */
.grade-circle-glow {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(145deg, #8f2e9f, #6d1d79);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  box-shadow: 0 0 12px rgba(131, 27, 145, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.grade-circle-glow.large {
  width: 100px;
  height: 100px;
  font-size: 2.2rem;
  box-shadow: 0 0 20px rgba(131, 27, 145, 0.45);
}

/* Sidebar Hierarchie */
.sidebar-years-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-sub-menu {
    background: rgba(0, 0, 0, 0.2);
    padding-left: 15px;
    margin-bottom: 10px;
}

.sub-tab-link {
    width: 100%;
    text-align: left;
    padding: 10px 15px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 0.85em;
    cursor: pointer;
    border-left: 2px solid transparent;
}

.sub-tab-link:hover { color: var(--primary-accent); }
.sub-tab-link.active { color: white; border-left-color: var(--primary-accent); }

/* Noten-Kacheln (Tiles) */
.grade-tile {
    width: 40px;
    height: 40px;
    background: #4caf50;
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 8px;
}

.add-grade-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid #555;
    background: transparent;
    color: white;
    cursor: pointer;
}

/* Abitur Zusammenfassung Dashboard */
.abi-summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.summary-card {
    background: #252525;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    border: 1px solid #333;
}

.summary-card strong { font-size: 1.4em; margin: 5px 0; }
.summary-card small { color: #666; font-size: 0.75em; }
.summary-card.glow { border-color: var(--primary-accent); }

/* Noten-Details & Gewichtung (Foto 1) */
.noten-card {
    background: #252525;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.card-section { margin-bottom: 20px; }

.section-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: #888;
    margin-bottom: 10px;
}

.grade-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.subject-action-bar {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    border-top: 1px solid #333;
    margin-top: 20px;
}

.btn-action {
    background: transparent;
    border: none;
    color: #888;
    font-size: 0.8em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

/* --- TABELLEN --- */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 20px;
}

th {
  background-color: var(--table-header-bg);
  color: var(--primary-accent);
  padding: 15px;
  text-transform: uppercase;
  font-size: 0.8em;
  letter-spacing: 1px;
}

td { padding: 12px; border-bottom: 1px solid #333; text-align: center; }

tr.highlighted { background-color: var(--highlight-color) !important; color: #000 !important; }
tr.completed { opacity: 0.4; text-decoration: line-through; }

/* --- NUTRITION DASHBOARD --- */
.charts-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  width: 100%;
  margin: 20px auto;
  max-width: var(--page-max-width);
}

body.page-healthtool .meal-log-section {
  width: 100%;
  max-width: var(--page-max-width);
  margin: 28px auto;
}

body.page-healthtool .meal-log-section > .card-header {
  position: sticky;
  top: 54px;
  z-index: 30;
  padding: 12px 0;
  background: var(--bg-primary);
}

body.page-healthtool .meal-type-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

body.page-healthtool .meal-type-button {
  min-height: 48px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
}

body.page-healthtool .meal-type-button.active,
body.page-healthtool .meal-type-button:hover {
  border-color: var(--primary-accent);
  background: color-mix(in srgb, var(--primary-accent) 18%, var(--bg-secondary));
}

body.page-healthtool .meal-log-panel {
  position: fixed;
  top: 76px;
  left: 50%;
  z-index: 1100;
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 108px);
  overflow-y: auto;
  transform: translateX(-50%);
  padding: 28px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background: var(--bg-secondary);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

body.page-healthtool .meal-log-panel-header {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 16px;
  background: var(--bg-secondary);
}

body.page-healthtool .meal-log-panel-header h3 {
  margin: 0;
}

body.page-healthtool .meal-log-panel .meal-log-toolbar,
body.page-healthtool .meal-log-panel .meal-log-table-container {
  min-width: 0;
}

body.page-healthtool .meal-log-toolbar {
  position: relative;
  margin-bottom: 16px;
}

body.page-healthtool .meal-search-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-weight: 600;
}

body.page-healthtool #meal-search-input {
  flex: 1;
  min-width: 0;
}

body.page-healthtool .meal-log-table-container {
  overflow-x: auto;
}

body.page-healthtool #meal-log-table {
  width: 100%;
  border-collapse: collapse;
}

body.page-healthtool #meal-log-table th,
body.page-healthtool #meal-log-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--input-border);
  text-align: left;
  white-space: nowrap;
}

body.page-healthtool #meal-log-table th {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
}

body.page-healthtool .table-actions {
  text-align: right !important;
}

body.page-healthtool #meal-search-results {
  position: absolute;
  top: 76px;
  left: 0;
  right: 150px;
  z-index: 20;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--input-border);
  background: var(--bg-secondary);
}

body.page-healthtool #meal-search-results .search-item {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid var(--input-border);
  background: transparent;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

body.page-healthtool #meal-search-results .search-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 768px) {
  body.page-healthtool {
    overflow-x: hidden;
  }

  body.page-healthtool .meal-type-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body.page-healthtool .meal-log-panel {
    top: 64px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 80px);
    padding: 12px;
  }

  body.page-healthtool .meal-log-panel-header {
    top: -12px;
    padding-bottom: 12px;
  }

  body.page-healthtool .meal-log-toolbar .inline-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  body.page-healthtool #meal-search-input {
    flex-basis: 100%;
    grid-column: 1 / -1;
    width: 100%;
  }

  body.page-healthtool .meal-log-toolbar .inline-input-row .btn-tasksC {
    grid-column: 1 / -1;
    width: 100%;
  }

  body.page-healthtool #meal-search-results {
    top: 118px;
    right: 0;
  }

  body.page-healthtool .meal-log-table-container {
    overflow: visible;
  }

  body.page-healthtool #meal-log-table,
  body.page-healthtool #meal-log-table thead,
  body.page-healthtool #meal-log-table tbody,
  body.page-healthtool #meal-log-table tr,
  body.page-healthtool #meal-log-table td {
    display: block;
    width: 100%;
  }

  body.page-healthtool #meal-log-table thead {
    display: none;
  }

  body.page-healthtool #meal-log-table tr {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--surface);
  }

  body.page-healthtool #meal-log-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
    padding: 7px 0;
    border-bottom: 1px solid var(--input-border);
    white-space: normal;
  }

  body.page-healthtool #meal-log-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  body.page-healthtool #meal-log-table td:last-child {
    border-bottom: 0;
    align-items: center;
  }

  body.page-healthtool #meal-log-table .table-actions {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    text-align: left !important;
  }
}

.chart-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.page-healthtool .tab-section {
  padding: 20px var(--page-side-padding) 32px;
}

body.page-healthtool h1,
body.page-healthtool h2 {
  max-width: var(--page-max-width);
  margin-left: auto;
  margin-right: auto;
}

body.page-healthtool #workout-form,
body.page-healthtool #workout-plan-form {
  width: 100%;
}

body.page-healthtool #workout-form,
body.page-healthtool #workout-plan-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
  align-items: start;
}

body.page-healthtool #workout-form > label,
body.page-healthtool #workout-plan-form > label {
  margin: 0;
  align-self: center;
  color: var(--text-muted);
  font-weight: 600;
}

body.page-healthtool #workout-form > input:not([type="hidden"]),
body.page-healthtool #workout-form > select,
body.page-healthtool #workout-form > textarea,
body.page-healthtool #workout-plan-form > input,
body.page-healthtool #workout-plan-form > select,
body.page-healthtool #workout-plan-form > textarea {
  width: 100%;
}

body.page-healthtool #workout-form > .workout-form-block,
body.page-healthtool #workout-form > .form-actions,
body.page-healthtool #workout-plan-form > .workout-form-block,
body.page-healthtool #workout-plan-form > .form-actions {
  grid-column: 1 / -1;
}

body.page-healthtool #workout-form textarea,
body.page-healthtool #workout-plan-form textarea {
  min-height: 96px;
}

body.page-healthtool .workout-dashboard-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.95fr);
  align-items: start;
}

body.page-healthtool .workout-dashboard-grid > .chart-card,
body.page-healthtool .workout-form-block,
body.page-healthtool .workout-exercise-list,
body.page-healthtool .stack-list,
body.page-healthtool .exercise-row,
body.page-healthtool .exercise-row > * {
  min-width: 0;
}

body.page-healthtool .tab-section {
  padding: 20px var(--page-side-padding) 32px;
}

body.page-healthtool h1,
body.page-healthtool h2 {
  max-width: var(--page-max-width);
  margin-left: auto;
  margin-right: auto;
}

body.page-healthtool #workout-form,
body.page-healthtool #workout-plan-form {
  width: 100%;
}

body.page-healthtool #workout-form,
body.page-healthtool #workout-plan-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
  align-items: start;
}

body.page-healthtool #workout-form > label,
body.page-healthtool #workout-plan-form > label {
  margin: 0;
  align-self: center;
  color: var(--text-muted);
  font-weight: 600;
}

body.page-healthtool #workout-form > input:not([type="hidden"]),
body.page-healthtool #workout-form > select,
body.page-healthtool #workout-form > textarea,
body.page-healthtool #workout-plan-form > input,
body.page-healthtool #workout-plan-form > select,
body.page-healthtool #workout-plan-form > textarea {
  width: 100%;
}

body.page-healthtool #workout-form > .workout-form-block,
body.page-healthtool #workout-form > .form-actions,
body.page-healthtool #workout-plan-form > .workout-form-block,
body.page-healthtool #workout-plan-form > .form-actions {
  grid-column: 1 / -1;
}

body.page-healthtool #workout-form textarea,
body.page-healthtool #workout-plan-form textarea {
  min-height: 96px;
}

body.page-healthtool .workout-dashboard-grid {
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  align-items: start;
}

body.page-healthtool .workout-dashboard-grid > .chart-card,
body.page-healthtool .workout-form-block,
body.page-healthtool .workout-exercise-list,
body.page-healthtool .stack-list,
body.page-healthtool .exercise-row,
body.page-healthtool .exercise-row > * {
  min-width: 0;
}

body.page-healthtool .workout-form-block,
body.page-healthtool .stack-list {
  width: 100%;
  overflow: hidden;
}

body.page-healthtool .workout-exercise-list {
  overflow-x: auto;
}

body.page-healthtool .workout-plan-card,
body.page-healthtool .workout-overview-card {
  width: 100%;
  min-height: 680px;
  height: auto;
  max-width: none;
}

body.page-healthtool .workout-plan-card {
  min-height: 820px;
}

body.page-healthtool .workout-overview-card {
  min-height: 820px;
}

body.page-healthtool .charts-grid-container {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  width: min(calc(100% - 24px), var(--page-max-width));
  margin: 20px auto;
  align-items: flex-start;
}

body.page-healthtool .chart-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  flex: 1 1 400px;
  min-width: 0;
  overflow: hidden;
}

body.page-healthtool .ingredient-form-card.modal-card-surface {
max-height: min(86vh, 920px);
overflow-y: auto;
overflow-x: hidden;
}



body.page-healthtool .nutrition-card,
body.page-healthtool .ingredient-card {
  width: 100%;
  min-width: 500px;
  max-width: 500px;
  min-height: 368px;
  height: 368px;
}

body.page-healthtool .nutrition-card .chart-inner-box,
body.page-healthtool .ingredient-card .recipe-preview-content {
  min-width: 0;
}

body.page-healthtool .calorie-card--wide {
  width: calc(100vw - 240px - (var(--page-side-padding) * 2) - 24px);
  max-width: calc(100vw - 240px - (var(--page-side-padding) * 2) - 24px);
  min-height: 220px;
  height: auto;
  margin-bottom: 25px;
}

body.page-healthtool .chart-legend {
  min-width: 0;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

body.page-healthtool .chart-inner-box {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: start;
  min-height: 0;
  gap: 20px;
}

body.page-healthtool .chart-inner-box svg {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  transform: rotate(-90deg);
}

body.page-healthtool .goal-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

body.page-healthtool .goal-input-label {
  color: var(--text-muted);
  font-weight: 600;
}

body.page-healthtool .calorie-card {
  min-height: 220px;
}

body.page-healthtool .charts-grid-container {
  grid-template-columns: repeat(3, minmax(336px, 1fr));
}


body.page-healthtool .modal-card-surface {
  width: min(960px, calc(100vw - 48px));
  max-width: min(960px, calc(100vw - 48px));
  max-height: min(86vh, 920px);
  overflow: auto;
}

body.page-healthtool .hidden-overlay {
  padding: 24px;
}

body.page-healthtool .hidden-overlay > .modal-card-surface {
  align-self: stretch;
}

body.page-healthtool .recipe-form-card,
body.page-healthtool .ingredient-form-card {
  display: grid;
  gap: 16px;
}

body.page-healthtool #add-recipe-form {
  align-items: flex-start;
}

body.page-healthtool #add-recipe-form .recipe-search-section {
  margin-top: 0;
}

body.page-healthtool .recipe-image-upload-zone {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--input-border);
  border-radius: 10px;
  background: var(--surface);
}

body.page-healthtool .recipe-image-upload-zone.drag-over {
  border-color: var(--primary-accent);
  background: rgba(131, 27, 145, 0.12);
}

body.page-healthtool .upload-label {
  font-weight: 700;
  color: var(--text-main);
}

body.page-healthtool .hidden-file-input {
  display: none;
}

body.page-healthtool .recipe-form-card textarea,
body.page-healthtool .ingredient-form-card textarea {
  width: 100%;
}

body.page-healthtool .chart-inner-box {
  grid-template-columns: 150px minmax(0, 1fr);
}

@media (max-width: 768px) {
  body.page-healthtool .chart-inner-box {
    grid-template-columns: 1fr;
  }

  body.page-healthtool .chart-inner-box svg {
    margin: 0 auto;
  }

  body.page-healthtool .chart-legend {
    margin-top: 12px;
    max-height: none;
  }
}

body.page-healthtool .ingredient-card {
  width: 100%;
  min-height: 368px;
  height: 368px;
}

body.page-healthtool .workout-exercise-list,
body.page-healthtool .stack-list {
  width: 100%;
  overflow: hidden;
}

body.page-healthtool .exercise-row {
  min-width: 860px;
}

body.page-healthtool .workout-exercise-list {
  overflow-x: auto;
}

body.page-healthtool .stack-card,
body.page-healthtool .stack-card p,
body.page-healthtool .muted-inline-note {
  overflow-wrap: anywhere;
}

body.page-healthtool .chart-legend {
  min-width: 0;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

.legend-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.legend-item-main{
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.legend-dot {
 width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background-color: var(--legend-dot-color, #999);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.nutrient-name {
  overflow-wrap: anywhere;
}

.nutrient-value {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chart-empty-note {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 4px 0;
}

.card-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  color: var(--text-muted);
}

body:not(.page-healthtool) .chart-inner-box { display: flex; flex-direction: row; align-items: center; gap: 30px; }
body:not(.page-healthtool) .chart-inner-box svg { width: 150px; height: 150px; flex-shrink: 0; transform: rotate(-90deg); }

circle { fill: transparent; stroke-width: 3; transition: stroke-dasharray 0.8s ease; }


/* --- CALORIE CARD --- */
.calorie-card { width: 100%; min-height: 120px; margin-bottom: 25px; }

.progress-track {
  width: 100%;
  height: 20px;
  background-color: #222;
  border-radius: 10px;
  margin: 15px 0;
  border: 1px solid #444;
  overflow: hidden;
}

.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary-accent), #b326c5); }

.table-container,
.workout-container,
.history-table-container {
  width: 100%;
  overflow-x: auto;
}

.panel-card,
.chart-card,
.noten-card,
.history-table-container,
.summary-card {
  border-radius: 14px;
}

.page-login,
.page-register,
.page-admin,
.page-tasks,
.page-agb,
.page-todolist,
.page-careerplanning,
.page-healthtool {
  min-height: 100vh;
}

.page-login h1,
.page-register h1 {
  text-align: center;
  margin-top: 28px;
}

.page-login form,
.page-register form {
  width: min(100%, 560px);
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

.page-admin h1,
.page-admin #users-table {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.page-admin #users-table {
  margin-top: 12px;
}

/* --- FORMULARE --- */
form {
  margin: 20px auto;
  width: min(calc(100% - 24px), var(--page-max-width));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 15px;
  background-color: var(--bg-secondary);
  padding: clamp(12px, 1.8vw, 20px);
  border-radius: 12px;
}

.embedded-form {
  margin: 0 0 18px;
}

.workout-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin: 20px auto;
  width: min(calc(100% - 24px), var(--page-max-width));
}

.workout-form-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compact-header {
  margin-bottom: 8px;
}

.compact-header h3,
.compact-header h4 {
  margin: 0;
}

.workout-exercise-list,
.stack-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exercise-row,
.stack-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 12px;
}

.exercise-row {
  display: grid;
  grid-template-columns: minmax(140px, 2fr) repeat(4, minmax(90px, 1fr)) minmax(140px, 2fr) auto;
  gap: 10px;
  align-items: center;
}

.stack-card p {
  margin: 8px 0 0;
}

.compact-card {
  padding: 10px 12px;
}

.muted-inline-note {
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 1200px) {
  body.page-healthtool #workout-form,
  body.page-healthtool #workout-plan-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

input, select, textarea {
  padding: 10px 12px;
  border-radius: 5px;
  border: 1px solid var(--input-border);
  background-color: #2b2b2b;
  color: white;
  min-height: var(--control-min-height);
}

body.theme-notebook input, 
body.theme-notebook select, 
body.theme-notebook textarea {
  background-color: #fffcf0;
  color: #3b2a1f;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .sub-navbar {
    flex-direction: row !important;
    overflow-x: auto;
    padding: 10px !important;
    position: sticky;
    top: 55px;
    z-index: 900;
    white-space: nowrap;
    width: 100%;
    border-bottom: 1px solid var(--input-border);
  }
  .sub-nav-link { padding: 10px 15px !important; border-left: none !important; border-bottom: 3px solid transparent; }
  .sub-nav-link.active { border-bottom: 3px solid var(--primary-accent); }
  .abi-summary-cards { grid-template-columns: 1fr; }
  .exercise-row {
    grid-template-columns: 1fr;
  }
  .workout-dashboard-grid {
    margin: 12px;
  }
}

.hidden { display: none !important; }

.hidden-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

body.page-healthtool #add-ingredient-overlay {
  display: none !important;
}

body.page-healthtool #add-ingredient-overlay.is-open {
  display: flex !important;
}

/* --- INLINE STYLE REPLACEMENTS (moved from HTML) --- */
#nutrition-content,
#recipe-content,
#ingredients-content,
#module-semester-list,
#module-abi-summary,
#addYearModal,
#abiGradeModal,
#interestModal,
#add-recipe-overlay,
#add-ingredient-overlay,
#todo-list-detail {
  display: none;
}

#current-date-display {
  font-weight: bold;
  margin: 0 15px;
}

#nutrition-logs-container {
  margin-top: 30px;
}

.recipe-search-section {
  position: relative;
  margin-top: 15px;
}

.inline-input-row {
  display: flex;
  gap: 5px;
}

#recipe-ingredients-table {
  margin-top: 10px;
  font-size: 0.9em;
}

.ingredient-db-search-section {
  position: relative;
  margin: 10px 20px;
}

#ing-db-search-input {
  width: 100%;
  max-width: 400px;
  padding: 10px;
  border-radius: 8px;
}

#ingredient-search-results {
  max-width: 400px;
}

#error {
  color: red;
}

.terms-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
}

.admin-error-text {
  color: red;
}

.admin-system-label {
  color: gray;
  font-size: 0.8em;
}

.recipe-card-image {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
}

.recipe-image-placeholder {
  width: 100%;
  height: 90px;
  border: 1px dashed #666;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  margin-bottom: 10px;
}

.inline-actions-row {
  display: flex;
  gap: 10px;
}

.recipe-filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 20px 10px;
}

.recipe-filter-row .btn-mini.active {
  background: var(--primary-accent);
  border-color: var(--primary-accent);
  color: #fff;
}

.self-created-card {
  border: 1px solid var(--primary-accent);
  box-shadow: 0 0 0 1px rgba(131, 27, 145, 0.2);
}

.system-created-card {
  border-style: dashed;
}

.creator-flag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--primary-accent);
  border: 1px solid var(--primary-accent);
}

.btn-mark-active {
  background-color: #f3b600;
  border-color: #f3b600;
  color: #1d1300;
}

.btn-danger-icon {
  color: #ff5252;
}

.compact-top-actions {
  margin-top: 10px;
}

.compact-top-actions-sm {
  margin-top: 15px;
  gap: 5px;
}

.muted-inline-note {
  color: #888;
}

.modal-card {
    max-width: 500px;
    width: 90%;
    background-color: var(--bg-main);
    border: 2px solid var(--primary-accent);
    padding: 30px;
    border-radius: 12px;
}

/* Scrollbars für Notebook Theme anpassen */
body.theme-notebook ::-webkit-scrollbar { width: 8px; }
body.theme-notebook ::-webkit-scrollbar-thumb { background: var(--primary-accent); border-radius: 10px; }

/* Global Scrollbar (Chromium, Edge, Safari) */
*::-webkit-scrollbar {
width: 10px;
height: 10px;
}

*::-webkit-scrollbar-track {
background: color-mix(in srgb, var(--bg-secondary) 78%, #000 22%);
border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
background: linear-gradient(
180deg,
color-mix(in srgb, var(--primary-accent) 78%, #fff 22%),
var(--primary-accent)
);
border: 2px solid color-mix(in srgb, var(--bg-secondary) 70%, #000 30%);
border-radius: 999px;
min-height: 28px;
}

*::-webkit-scrollbar-thumb:hover {
background: color-mix(in srgb, var(--primary-accent) 88%, #fff 12%);
}

*::-webkit-scrollbar-corner {
background: transparent;
}

/* Firefox */
* {
scrollbar-width: thin;
scrollbar-color: var(--primary-accent) color-mix(in srgb, var(--bg-secondary) 78%, #000 22%);
}

/* Notebook Theme Adaption für Glow Noten */
body.theme-notebook .grade-circle-glow {
    background: var(--primary-accent);
    box-shadow: 0 0 10px rgba(139, 94, 60, 0.4);
}

.grid-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 16px;
  min-width: 0;
}

.panel-card {
  background: #262626;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 16px;
  min-width: min(100%, 320px);
  min-height: 260px;
  overflow: visible;
}

.page-careerplanning .panel-card-wide {
  min-width: min(100%, 420px);
}

.page-careerplanning .tab-section,
.page-careerplanning .career-module,
.page-careerplanning .history-table-container,
.page-careerplanning .noten-card,
.page-careerplanning .summary-card {
  min-width: 0;
  overflow: visible;
}

.page-careerplanning .panel-card .history-table,
.page-careerplanning .history-table-container .history-table {
  width: 100%;
  max-width: 100%;
}

.page-careerplanning .panel-card .table-scroll-wrap,
.page-careerplanning .history-table-container .table-scroll-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 1400px) {
  .page-careerplanning .panel-card-wide {
    min-width: min(100%, 360px);
  }
}

.page-careerplanning .toolbar-row,
.page-careerplanning .history-summary-list,
.page-careerplanning .avg-meta-grid,
.page-careerplanning #interest-chips {
  min-width: 0;
}

.page-careerplanning .history-chip,
.page-careerplanning .interest-chip,
.page-careerplanning h1,
.page-careerplanning h2,
.page-careerplanning h3,
.page-careerplanning p,
.page-careerplanning td,
.page-careerplanning th {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.gpa-hero {
  display: grid;
  gap: 12px;
}

.avg-hero-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.avg-grade-orb {
  width: 98px;
  height: 98px;
  border-radius: 16px;
  background: rgba(131, 27, 145, 0.14);
  color: var(--primary-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.95rem;
  font-weight: 700;
  border: 1px solid rgba(131, 27, 145, 0.5);
  box-shadow: none;
}

body.theme-notebook .avg-grade-orb {
  background: linear-gradient(145deg, #8b5e3c, #6f472b);
}

.avg-hero-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--text-muted);
  width: 100%;
}

.avg-status-pill {
  border: 1px solid rgba(131, 27, 145, 0.45);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  color: #d9a9df;
  background: rgba(131, 27, 145, 0.12);
}

.avg-status-pill.level-strong {
  border-color: rgba(189, 83, 206, 0.62);
  color: #f0c4f6;
}

.avg-status-pill.level-mid {
  border-color: rgba(159, 60, 176, 0.52);
  color: #e2a7ea;
}

.avg-status-pill.level-risk {
  border-color: rgba(109, 29, 121, 0.62);
  color: #c98fd2;
}

.avg-progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(131, 27, 145, 0.12);
  border: 1px solid rgba(131, 27, 145, 0.35);
}

.avg-progress-fill {
  height: 100%;
  width: 0;
  transition: width 0.35s ease;
  background: linear-gradient(90deg, #c05ccc, #831b91);
}

.avg-progress-fill.level-mid {
  background: linear-gradient(90deg, #b24abf, #7a2288);
}

.avg-progress-fill.level-risk {
  background: linear-gradient(90deg, #8c2f9a, #63196f);
}

.avg-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.avg-meta-item {
  background: rgba(131, 27, 145, 0.08);
  border: 1px solid rgba(131, 27, 145, 0.25);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 3px;
}

.avg-meta-item span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.avg-meta-item strong {
  color: var(--text-main);
  font-size: 0.95rem;
}

body.theme-notebook .panel-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #c7a97b;
}

body.theme-notebook .avg-meta-item {
  background: #f3e7d1;
  border-color: #d0b285;
}

.toolbar-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}

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

.small-text {
  font-size: 0.9rem;
}

.history-summary-list {
  display: grid;
  gap: 8px;
}

.history-chip {
  border: 1px solid #3e3e3e;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 2px;
  background: #202020;
}

body.theme-notebook .history-chip {
  background: #f5ebd8;
  border: 1px solid #d0b285;
}

.year-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.year-inline-hint {
  margin: 0 20px 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.year-badge {
  background: var(--primary-accent);
  color: white;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
}

.table-scroll-wrap {
  overflow-x: auto;
  width: 100%;
}

.abi-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.abi-settings-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.abi-cell-wrap {
  display: grid;
  gap: 5px;
  justify-items: center;
}

.abi-sem-btn {
  width: 64px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid #666;
  background: #2d2d2d;
  color: #f2f2f2;
  font-weight: 700;
  cursor: pointer;
}

.abi-sem-btn:hover {
  background: #3a3a3a;
}

.abi-cell-wrap.projected .abi-sem-btn {
  border-color: #6f6f6f;
  color: #d0d0d0;
}

.abi-cell-wrap.projected-default .abi-sem-btn {
  background: rgba(255, 255, 255, 0.03);
}

.abi-cell-wrap.projected-average .abi-sem-btn {
  background: rgba(255, 255, 255, 0.06);
}

.abi-cell-wrap.deficit .abi-sem-btn {
  border-color: rgba(204, 73, 73, 0.75);
  background: rgba(168, 46, 46, 0.2);
  color: #ffb6b6;
}

.abi-cell-wrap.not-enrolled .abi-sem-btn {
  border-color: rgba(204, 73, 73, 0.9);
  color: #ff9696;
}

.abi-slash-flag {
  color: #ff4a4a;
  font-weight: 700;
  line-height: 1;
}

.abi-projection-hint {
  color: #9e9e9e;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.abi-deficit-hint {
  color: #ff8d8d;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.abi-not-enrolled-btn {
  font-size: 0.66rem;
  padding: 2px 7px;
  min-height: auto;
  background: #2a2a2a;
  border: 1px solid #555;
}

.abi-not-enrolled-btn.active {
  background: #505050;
  border-color: #888;
}

.deficit-box {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.deficit-box.ok {
  background: rgba(46, 125, 50, 0.16);
  border-color: rgba(46, 125, 50, 0.45);
  color: #8be892;
}

.deficit-box.mid {
  background: rgba(201, 155, 24, 0.2);
  border-color: rgba(201, 155, 24, 0.55);
  color: #ffd874;
}

.deficit-box.warn {
  background: rgba(168, 46, 46, 0.17);
  border-color: rgba(168, 46, 46, 0.45);
  color: #ff9d9d;
}

.regular-composite-cell {
  color: #f0f0f0;
  font-weight: 700;
}

.subject-share-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.share-input {
  width: 56px;
  text-align: center;
}

.share-sum-hint,
.abi-share-hint {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.share-sum-ok {
  color: #87d69f;
}

.share-sum-adjusted {
  color: #f6ce72;
}

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

.abi-exam-auto-row td {
  color: #9f9f9f;
  font-style: italic;
}

.abi-grade-modal-card {
  max-width: 560px;
  background: var(--bg-main);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 14px 32px var(--shadow-color);
}

.abi-grade-semester-label {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.abi-grade-subject-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: color-mix(in srgb, var(--bg-secondary) 78%, #000 22%);
}

.abi-grade-subject-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--primary-accent);
  background: color-mix(in srgb, var(--primary-accent) 30%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-accent) 12%, transparent);
}

.abi-grade-subject-row h3 {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
  color: var(--text-main);
}

.abi-grade-orb {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--text-main);
  border: 1px solid color-mix(in srgb, var(--primary-accent) 64%, var(--input-border) 36%);
  background: color-mix(in srgb, var(--primary-accent) 22%, var(--bg-main) 78%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-accent) 10%, transparent);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
  animation: abi-orb-accent 3.6s ease-in-out infinite;
}

.abi-grade-modal-card:hover .abi-grade-orb {
  border-color: color-mix(in srgb, var(--primary-accent) 80%, var(--input-border) 20%);
  background: color-mix(in srgb, var(--primary-accent) 28%, var(--bg-main) 72%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-accent) 18%, transparent);
}

@keyframes abi-orb-accent {
  0%,
  100% {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-accent) 10%, transparent);
  }
  50% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-accent) 18%, transparent);
  }
}

.abi-grade-block {
  margin-top: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 12px;
}

.abi-grade-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.abi-grade-block-header strong {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.abi-grade-share-input {
  width: 54px;
  min-height: 30px;
  text-align: center;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--primary-accent) 45%, var(--input-border) 55%);
  background: color-mix(in srgb, var(--bg-main) 75%, var(--primary-accent) 25%);
  color: var(--text-main);
  font-weight: 700;
  padding: 4px 6px;
}

.abi-grade-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.abi-grade-note-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.abi-grade-note-list.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.abi-grade-note-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--primary-accent) 55%, var(--input-border) 45%);
  background: color-mix(in srgb, var(--primary-accent) 22%, var(--bg-main) 78%);
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 700;
}

.abi-grade-note-chip small {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1;
}

.abi-grade-chip-input {
  width: 74px;
  min-height: 38px;
  text-align: center;
  background: color-mix(in srgb, var(--bg-main) 55%, var(--primary-accent) 45%);
  border: 1px solid color-mix(in srgb, var(--primary-accent) 60%, var(--input-border) 40%);
  border-radius: 8px;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1rem;
}

.abi-grade-add-btn {
  min-width: 38px;
  min-height: 38px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 800;
}

.abi-grade-final-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.abi-grade-final-btn {
  width: 86px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: color-mix(in srgb, var(--bg-main) 72%, #fff 28%);
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
}

.abi-grade-final-btn:disabled {
  opacity: 0.7;
}

#interest-settings .toolbar-row {
  margin: 8px 0 12px;
  gap: 8px;
}

.interest-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--primary-accent) 50%, var(--input-border) 50%);
  background: color-mix(in srgb, var(--surface) 78%, var(--primary-accent) 22%);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
}

.interest-chip.region {
  background: color-mix(in srgb, var(--primary-accent) 35%, var(--surface) 65%);
}

.interest-chip.muted {
  border-color: var(--input-border);
  color: var(--text-muted);
  background: var(--surface);
}

.interest-modal-card {
  max-width: 520px;
  background: var(--bg-main);
  border: 1px solid var(--input-border);
  box-shadow: 0 14px 32px var(--shadow-color);
}

.abi-grade-checkbox-row {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.abi-grade-modal-actions {
  margin-top: 14px;
  justify-content: flex-end;
}

.modal-card label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 768px) {
  .history-table {
    min-width: 640px;
  }

  .avg-meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .abi-grade-modal-card {
    width: 94%;
    padding: 14px;
  }

  .abi-grade-subject-row h3 {
    font-size: 1.12rem;
  }

  .abi-grade-orb {
    width: 54px;
    height: 54px;
    font-size: 1.08rem;
    border-radius: 12px;
  }

  .abi-grade-final-row {
    align-items: flex-start;
  }
}

/* Mobile cards and stacked tables for the primary study, health and career views. */
.study-task-cards {
  display: none;
}

@media (max-width: 900px) {
  body.page-healthtool .calorie-card--wide {
    width: 100%;
    max-width: none;
    min-height: 0;
    padding: 16px;
  }

  body.page-healthtool .calorie-card--wide .card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  body.page-healthtool .calorie-card--wide .goal-input-group {
    width: 100%;
  }

  body.page-healthtool .calorie-card--wide .goal-input-group input {
    flex: 1;
    min-width: 0;
  }

  body.page-healthtool .progress-track {
    height: 16px;
    margin: 12px 0;
  }

  body.page-healthtool .calorie-stats-text {
    text-align: center;
  }

  body.page-healthtool .workout-container,
  body.page-healthtool #workouts-table,
  body.page-careerplanning .panel-card-wide .table-scroll-wrap,
  body.page-careerplanning .panel-card-wide .history-table {
    overflow: visible;
    width: 100%;
    min-width: 0;
  }

  body.page-healthtool #workouts-table,
  body.page-healthtool #workouts-table thead,
  body.page-healthtool #workouts-table tbody,
  body.page-healthtool #workouts-table tr,
  body.page-healthtool #workouts-table td,
  body.page-careerplanning .panel-card-wide .history-table,
  body.page-careerplanning .panel-card-wide .history-table thead,
  body.page-careerplanning .panel-card-wide .history-table tbody,
  body.page-careerplanning .panel-card-wide .history-table tr,
  body.page-careerplanning .panel-card-wide .history-table td {
    display: block;
    width: 100%;
  }

  body.page-healthtool #workouts-table thead,
  body.page-careerplanning .panel-card-wide .history-table thead {
    display: none;
  }

  body.page-healthtool #workouts-table tr,
  body.page-careerplanning .panel-card-wide .history-table tr {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--surface);
  }

  body.page-healthtool #workouts-table td,
  body.page-careerplanning .panel-card-wide .history-table td {
    display: grid;
    grid-template-columns: minmax(94px, 35%) minmax(0, 1fr);
    gap: 10px;
    align-items: baseline;
    padding: 7px 0;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  body.page-healthtool #workouts-table td::before,
  body.page-careerplanning .panel-card-wide .history-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  body.page-healthtool #workouts-table .table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  body.page-careerplanning .panel-card-wide .history-table td:last-child {
    border-bottom: 0;
  }

  .page-tasks .table-container {
    display: none;
  }

  .page-tasks .study-task-cards {
    display: grid;
    gap: 12px;
    width: calc(100% - 24px);
    margin: 0 12px 20px;
  }

  .study-task-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--surface);
  }

  .study-task-card.highlighted {
    background: var(--highlight-color);
    color: #000;
  }

  .study-task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
  }

  .study-task-card-header strong {
    overflow-wrap: anywhere;
  }

  .study-task-card-header span,
  .study-task-card-meta {
    color: var(--text-muted);
    font-size: 0.86rem;
  }

  .study-task-card.highlighted .study-task-card-header span,
  .study-task-card.highlighted .study-task-card-meta {
    color: #333;
  }

  .study-task-card-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .study-task-card-actions .btn {
    width: 100%;
  }
}

/* --- TODO LIST PAGE --- */
.page-todolist .todo-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px var(--page-side-padding) 20px;
  width: min(100%, var(--page-max-width));
  margin: 0 auto;
}

.page-todolist .todo-sidebar,
.page-todolist .todo-main {
  border: 1px solid var(--input-border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 8px 22px var(--shadow-color);
}

.page-todolist .todo-sidebar {
  padding: 14px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.page-todolist .todo-sidebar h1 {
  margin: 0;
  font-size: 1.25rem;
}

.todo-form-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--surface-strong);
}

.todo-filter-label {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.todo-lists {
  display: grid;
  gap: 8px;
}

.todo-list-entry {
  width: 100%;
  text-align: left;
  border: 1px solid var(--input-border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.todo-list-entry.active {
  border-color: var(--primary-accent);
  box-shadow: inset 0 0 0 1px var(--primary-accent);
}

.todo-list-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  flex-shrink: 0;
}

.todo-list-copy {
  display: grid;
  gap: 2px;
}

.todo-list-copy small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.todo-main {
  padding: 16px;
  min-height: 68vh;
}

.todo-empty-state {
  padding: 20px;
  border: 1px dashed var(--input-border);
  border-radius: 10px;
}

.todo-detail {
  display: grid;
  gap: 14px;
}

.todo-detail-header,
.todo-share-box,
.todo-items-box {
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-strong);
}

.todo-detail-title-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.todo-detail-title-wrap input[type="text"] {
  flex: 1 1 260px;
}

.todo-share-form,
.todo-item-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.todo-item-tools-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.todo-item-tools-row input,
.todo-item-tools-row select {
  min-width: 170px;
  flex: 1;
}

.todo-share-list {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.todo-share-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  padding: 5px 10px;
  width: fit-content;
  background: rgba(255, 255, 255, 0.04);
}

.todo-share-role-select,
.todo-item-type-select,
#todo-share-permission,
#todo-item-persistence {
  min-width: 130px;
}

.todo-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.todo-items {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.todo-item-row {
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
}

.todo-item-row.completed {
  opacity: 0.72;
}

.todo-item-check {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.todo-item-row.completed .todo-item-check span {
  text-decoration: line-through;
}

.todo-item-actions {
  display: flex;
  gap: 6px;
}

/* --- MOBILE GLOBAL --- */
@media (max-width: 900px) {
  .navbar {
    padding: 10px 12px;
    gap: 8px;
    align-items: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .navbar .nav-link,
  .navbar .admin-link,
  .navbar .btn,
  .navbar .settings-container {
    flex: 0 0 auto;
  }

  .nav-link,
  .admin-link,
  .settings-btn {
    font-size: 0.9rem;
    padding: 7px 10px;
  }

  h1, h2, h3, h4 {
    margin: 14px;
  }

  form {
    margin: 0 12px 14px;
    padding: 12px;
  }

  .tab-section {
    padding: 12px;
  }

  .page-agb main {
    max-width: 100%;
    padding: 14px;
  }

  .panel-card,
  .chart-card,
  .noten-card,
  .history-table-container,
  .summary-card {
    border-radius: 10px;
  }

  .settings-menu {
    position: fixed;
    right: 10px;
    top: 62px;
    max-width: calc(100vw - 20px);
  }

  .settings-panel {
    min-width: min(320px, calc(100vw - 20px));
    max-height: calc(100vh - 100px);
    overflow: auto;
  }

  .stats-mini-bar {
    margin: 10px 12px;
    min-width: 0;
    width: calc(100% - 24px);
  }

  #tasks-table,
  #workouts-table,
  .history-table {
    min-width: 640px;
  }

  body.page-healthtool .workout-dashboard-grid {
    grid-template-columns: 1fr;
  }

  body.page-healthtool .chart-card {
    min-height: 0;
    padding: 20px;
  }

  body.page-healthtool .exercise-row {
    min-width: 0;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body.page-healthtool,
  body.page-careerplanning {
    display: block;
  }

  .page-admin #users-table,
  #tasks-table,
  #workouts-table,
  .history-table {
    display: block;
    white-space: nowrap;
  }

  .page-admin h1,
  .page-tasks h1,
  .page-healthtool h1,
  .page-careerplanning h1,
  .page-todolist h1,
  .page-agb h1 {
    margin-left: 10px;
    margin-right: 10px;
  }

  .sub-navbar {
    top: 54px;
  }

  .toolbar-row {
    gap: 8px;
  }

  body.page-healthtool .chart-card {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  body.page-healthtool .calorie-card--wide,
  body.page-healthtool .nutrition-card,
  body.page-healthtool .ingredient-card,
  body.page-healthtool .workout-plan-card,
  body.page-healthtool .workout-overview-card,
  body.page-healthtool .modal-card-surface {
    width: 100%;
    max-width: none;
    min-height: 0;
    height: auto;
  }

  body.page-healthtool .workout-plan-card,
  body.page-healthtool .workout-overview-card {
    min-height: 0;
  }

  body.page-healthtool .charts-grid-container {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .page-todolist .todo-layout {
    grid-template-columns: 1fr;
    padding: 12px;
    width: 100%;
  }

  .todo-item-row {
    flex-direction: column;
    align-items: stretch;
  }

  .todo-item-actions {
    justify-content: flex-end;
  }

  .todo-item-tools-row input,
  .todo-item-tools-row select,
  .todo-share-form input,
  .todo-share-form select,
  .todo-item-form input,
  .todo-item-form select {
    width: 100%;
    min-width: 0;
  }

  .todo-share-chip {
    width: 100%;
    border-radius: 10px;
  }
}

@media (max-width: 640px) {
  form {
    margin: 0 10px 12px;
    padding: 12px;
    gap: 10px;
  }

  form input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
  form select,
  form textarea,
  form button,
  form .btn {
    width: 100%;
  }

  .chart-card {
    padding: 14px;
  }

  body.page-healthtool .chart-inner-box {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  body.page-healthtool .chart-legend {
    max-height: 180px;
  }

  .grade-circle-glow.large {
    width: 84px;
    height: 84px;
    font-size: 1.8rem;
  }

  .modal-card {
    width: 94%;
    padding: 16px;
  }
}

@media (max-width: 900px) {
  body.page-healthtool #workouts-table,
  body.page-careerplanning .panel-card-wide .history-table,
  body.page-tasks #tasks-table {
    min-width: 0;
  }

  body.page-healthtool #workouts-table,
  body.page-careerplanning .panel-card-wide .history-table,
  body.page-tasks #tasks-table {
    white-space: normal;
  }
}