:root {
  --sage: #7ea08c;
  --sage-dark: #5f8571;
  --bg: #f7f8f6;
  --sidebar-bg: #ffffff;
  --border: #e4e7e3;
  --text: #2c332e;
  --muted: #8a938d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* --- Login --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--sage), var(--sage-dark));
}
.login-box {
  background: #fff;
  padding: 2.5rem;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-box h1 { margin: 0 0 .5rem; color: var(--sage-dark); text-align: center; }
.login-box label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
.login-box input {
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}
.login-box button {
  background: var(--sage);
  color: #fff;
  border: none;
  padding: .7rem;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: .5rem;
}
.login-box button:hover { background: var(--sage-dark); }
.login-box .error { color: #c0392b; font-size: .85rem; margin: 0; }

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: .8rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.progress-wrap { flex: 1; min-width: 200px; }
.progress-label { font-size: .75rem; font-weight: 600; color: var(--sage-dark); letter-spacing: .05em; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: .3rem; overflow: hidden; }
.progress-fill { height: 100%; background: var(--sage); }
.topbar-nav a { color: var(--text); text-decoration: none; font-size: .9rem; }
.topbar-nav a:hover { color: var(--sage-dark); }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--sage-dark); font-size: .9rem; font-weight: 600;
}
.topbar-user { font-size: .9rem; color: var(--muted); }

/* --- Layout --- */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 300px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
}
.sidebar-title {
  font-weight: 700;
  padding: 0 1.2rem 1rem;
  color: var(--sage-dark);
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
}
.lesson-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.lesson-list li a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1.2rem;
  text-decoration: none;
  color: var(--text);
  font-size: .9rem;
  border-left: 3px solid transparent;
}
.lesson-list li.active a { background: #f0f4f1; border-left-color: var(--sage); font-weight: 600; }
.lesson-list li a:hover { background: #f5f7f5; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.dot.done { background: var(--sage); border-color: var(--sage); }
.resync {
  display: block;
  padding: .6rem 1.2rem;
  font-size: .8rem;
  color: var(--muted);
  text-decoration: none;
  border-top: 1px solid var(--border);
}
.resync:hover { color: var(--sage-dark); }

/* --- Content --- */
.content { flex: 1; padding: 2rem 3rem; max-width: 900px; }
.content h1 { margin: 0 0 .8rem; font-size: 2rem; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #eef1ee;
  padding: .6rem 1rem;
  border-radius: 8px;
  font-size: .85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.badge {
  margin-left: auto;
  background: #ddd;
  color: #555;
  padding: .2rem .7rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
}
.badge-done { background: var(--sage); color: #fff; }

.media-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: center;
}
.media-card video, .media-card img { max-width: 100%; border-radius: 8px; }

.materials {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
}
.materials h2 { font-size: 1rem; margin: 0 0 .6rem; color: var(--sage-dark); }
.materials ul { margin: 0; padding-left: 1.2rem; }
.materials a { color: var(--text); }
.materials a:hover { color: var(--sage-dark); }

.bottom-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.pill {
  padding: .6rem 1.4rem;
  border-radius: 999px;
  background: var(--sage);
  color: #fff;
  text-decoration: none;
  font-size: .9rem;
  border: none;
  cursor: pointer;
}
.pill:hover { background: var(--sage-dark); }
.pill-primary { font-weight: 600; }
.muted { color: var(--muted); }

/* --- Startseite / Uebersicht --- */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
}
.overview-card {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .15s, transform .15s;
}
.overview-card:hover { box-shadow: 0 6px 16px rgba(0,0,0,.1); transform: translateY(-2px); }
.overview-card img { width: 100%; height: 130px; object-fit: cover; display: block; }
.overview-noimg {
  width: 100%; height: 130px;
  display: flex; align-items: center; justify-content: center;
  background: #eef1ee; color: var(--sage); font-size: 1.6rem;
}
.overview-info { padding: .8rem 1rem; display: flex; flex-direction: column; gap: .3rem; }
.ov-num { font-size: .75rem; color: var(--muted); }
.ov-title { font-weight: 600; font-size: .95rem; }
.overview-info .badge { align-self: flex-start; margin-left: 0; }

/* --- Hamburger-Button (nur mobil sichtbar, siehe Media Query unten) --- */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  cursor: pointer;
  flex: none;
}
.hamburger-btn span { display: block; height: 3px; width: 100%; background: var(--sage-dark); border-radius: 2px; }
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40;
}

/* --- Mobil (z.B. iPhone 11 Pro, 375px breit) --- */
@media (max-width: 780px) {
  .topbar {
    padding-top: calc(.6rem + env(safe-area-inset-top));
    gap: .8rem;
  }
  .hamburger-btn { display: flex; }
  .topbar-nav { display: none; }
  .topbar-user { display: none; }

  .layout { flex-direction: column; min-height: auto; }

  .sidebar {
    position: fixed;
    top: 0;
    left: -88%;
    width: 88%;
    max-width: 340px;
    height: 100vh;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,.25);
    transition: left .25s ease;
    padding-top: calc(1rem + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.nav-open .sidebar { left: 0; }
  body.nav-open .nav-backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  .sidebar-title { font-size: 1.2rem; padding-bottom: 1rem; }
  .lesson-list li a {
    font-size: 1.1rem;
    padding: 1rem 1.2rem;
  }
  .resync { font-size: .95rem; padding: .9rem 1.2rem; }

  .content { padding: 1.2rem 1rem 2rem; max-width: 100%; }
  .content h1 { font-size: 1.4rem; }
  .breadcrumb { font-size: .75rem; flex-wrap: wrap; }

  .bottom-nav { flex-wrap: wrap; justify-content: center; }
  .bottom-nav .pill, .bottom-nav form { flex: 1 1 100%; }
  .pill { text-align: center; display: block; }

  .overview-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
}
