:root {
  --green-900: #1b5e20;
  --green-700: #2e7d32;
  --green-500: #4caf50;
  --green-200: #c8e6c9;
  --green-100: #e8f5e9;
  --bg: #f1f8e9;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--green-900);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.no-scroll { overflow: hidden; }

.topbar {
  background: linear-gradient(90deg, var(--green-700), var(--green-500));
  color: white;
  padding: 1rem;
}

.topbar h1 { margin: 0 0 .5rem 0; font-size: 1.3rem; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .5rem; }
.topbar a { color: white; text-decoration: none; background: rgba(255,255,255,.15); padding: .45rem .7rem; border-radius: 10px; }

.topbar-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
}

.topbar-nav-left {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.topbar-user-right {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.topbar-user-label {
  color: #eaf7ea;
  font-size: .92rem;
}

.container { max-width: 980px; margin: 1rem auto; padding: 0 1rem 2rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .9rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }

.card {
  background: white;
  border: 1px solid var(--green-200);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.04);
}

.card.action { text-decoration: none; color: var(--green-900); font-weight: 600; }
.narrow { max-width: 420px; margin: 2rem auto; }

button, .btn {
  background: var(--green-700);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .6rem .9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-small { font-size: .9rem; padding: .45rem .65rem; }
.btn-secondary { background: #78909c; }
.mt-1 { margin-top: .8rem; }

input, select, textarea {
  width: 100%;
  padding: .6rem;
  border: 1px solid #b7d6ba;
  border-radius: 8px;
}
label { display: block; font-weight: 600; margin-bottom: .25rem; }
p { line-height: 1.4; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .5rem;
  z-index: 9999;
}

.hidden { display: none; }

.modal-content {
  width: 100%;
  max-width: 340px;
  background: white;
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid var(--green-200);
}

.modal-actions {
  display: flex;
  gap: .5rem;
  margin-top: .8rem;
}

.pin-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.pin-display {
  width: 100%;
  min-height: 44px;
  border: 1px solid #b7d6ba;
  border-radius: 10px;
  background: #f7fbf7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  letter-spacing: .24rem;
  font-weight: 700;
  color: var(--green-900);
  margin-top: .2rem;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: .55rem;
  margin-top: .8rem;
  width: 100%;
}

.pin-key {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: 700;
  padding: .4rem;
  line-height: 1;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.pin-key-secondary {
  background: #607d8b;
}

.pin-key-enter {
  background: var(--green-500);
}

@media (max-width: 480px) {
  .modal-content {
    max-width: 96vw;
    padding: 1rem .85rem;
  }

  .pin-key {
    min-height: 60px;
    font-size: 1.3rem;
  }

  .pin-display {
    min-height: 50px;
    font-size: 1.45rem;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

.thumb {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: .5rem;
}

.list-image-btn {
  background: transparent;
  border: 0;
  padding: 0;
  width: 100%;
  position: relative;
  z-index: 2;
}

.plant-list-card {
  position: relative;
  padding: 1rem;
}

.plant-text-link {
  position: relative;
  z-index: 1;
  display: block;
  text-decoration: none;
  color: var(--green-900);
}

.plant-text-link h3,
.plant-text-link p {
  margin: 0 0 .42rem 0;
  line-height: 1.36;
}

.plant-text-link .plant-botanic {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.plant-text-link .plant-title {
  font-size: .98rem;
  font-weight: 500;
  line-height: 1.32;
}

.plant-text-link p {
  font-size: .95rem;
  font-weight: 400;
}

.plant-text-link strong {
  font-weight: 700;
}

.detail-img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 10px;
}

.detail-banner {
  margin-bottom: .75rem;
  height: 200px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--green-200);
  background: #f5faf5;
  position: relative;
}

.detail-banner-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center center;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: .9rem;
}

@media (min-width: 900px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.muted {
  color: #3f5360;
  font-size: .95rem;
  line-height: 1.42;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.dashboard-filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: .5rem;
  align-items: stretch;
  margin-bottom: .8rem;
}

.dashboard-presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
}

.dashboard-presets .btn {
  width: 100%;
}

.dashboard-date-field label {
  margin-bottom: .2rem;
}

.dashboard-apply-btn {
  width: 100%;
}

.dashboard-filters input[type="date"] {
  min-width: 140px;
}

.dashboard-today-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin-top: .8rem;
}

.today-chip {
  border: 1px solid var(--green-200);
  border-radius: 10px;
  padding: .45rem .6rem;
  font-size: .92rem;
  background: #fff;
}

.today-chip-falsch {
  border-color: #ef9a9a;
  background: #ffebee;
}

.today-chip-unsicher {
  border-color: #ffcc80;
  background: #fff3e0;
}

.today-chip-gewusst {
  border-color: #a5d6a7;
  background: #e8f5e9;
}

.lernstatus-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
}

.lernstatus-chip {
  border: 1px solid var(--green-200);
  border-radius: 10px;
  padding: .45rem .55rem;
  background: #f9fff9;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

.lernstatus-chip span {
  font-size: .78rem;
  color: #4a6251;
}

.lernstatus-chip strong {
  font-size: .95rem;
}

.lernstatus-counts {
  margin-top: .45rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
}

.lernstatus-count {
  border: 1px solid var(--green-200);
  border-radius: 10px;
  padding: .38rem .5rem;
  font-size: .88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lernstatus-count-good { background: #e8f5e9; border-color: #a5d6a7; }
.lernstatus-count-mid { background: #fff3e0; border-color: #ffcc80; }
.lernstatus-count-bad { background: #ffebee; border-color: #ef9a9a; }

.ranking-list {
  margin: .4rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: .45rem;
}

.ranking-item {
  padding: .35rem .2rem;
  border-bottom: 1px dashed var(--green-200);
}

.ranking-item a {
  color: var(--green-900);
  text-decoration: none;
}

.ranking-item a:hover {
  text-decoration: underline;
}

.sentinel { text-align: center; padding: .8rem; color: #456; }

.gallery-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
}

@media (min-width: 900px) {
  .gallery-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.gallery-thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--green-200);
}

.thumb-btn {
  background: transparent;
  border: 0;
  padding: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
}

.gallery-item { display: flex; flex-direction: column; gap: .45rem; }

.gallery-item .thumb-btn { display: block; }

.thumb-overlay-caption {
  position: absolute;
  left: .35rem;
  right: .35rem;
  bottom: .35rem;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  padding: .22rem .4rem;
  border-radius: 6px;
  font-size: .82rem;
  text-align: left;
}

.inline-edit {
  display: grid;
  gap: .35rem;
}

.repeat-bias-buttons {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.block-pflanzen-details {
  margin-top: .45rem;
  border: 1px solid var(--green-200);
  border-radius: 10px;
  padding: .35rem .55rem;
  background: #f8fcf8;
}

.block-pflanzen-details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--green-900);
}

.block-pflanzen-liste {
  margin: .45rem 0 .2rem 1rem;
  padding: 0;
  display: grid;
  gap: .2rem;
}

.block-pflanzen-link {
  color: var(--green-900);
  text-decoration: none;
}

.block-pflanzen-link:hover {
  text-decoration: underline;
}

.inline-edit input[type="text"],
.inline-edit input[type="number"] { padding: .45rem; }

.inline-edit label { margin: 0; font-size: .88rem; }

.gallery-item .modal-actions {
  display: flex;
  justify-content: flex-start;
}

.image-actions {
  display: flex;
  gap: .45rem;
  align-items: center;
  flex-wrap: nowrap;
}

.image-actions form { margin: 0; }

.slideshow-content {
  width: min(980px, 100vw);
  height: min(92vh, 100vh);
  background: transparent;
  border-radius: 12px;
  padding: .2rem;
  touch-action: none;
  position: relative;
}

.close-x {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 0;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  z-index: 10001;
}

.slideshow-image {
  width: 100%;
  height: calc(92vh - 80px);
  object-fit: contain;
  background: #000;
  border-radius: 10px;
}

.slideshow-image-wrap {
  position: relative;
}

.slideshow-caption {
  position: absolute;
  left: .6rem;
  bottom: .6rem;
  max-width: calc(100% - 1.2rem);
  background: rgba(0,0,0,.6);
  color: #fff;
  padding: .35rem .55rem;
  border-radius: 8px;
  font-size: .9rem;
}

.slideshow-controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .7rem;
  margin-top: .7rem;
}

.slide-dots {
  display: flex;
  justify-content: center;
  gap: .35rem;
  flex-wrap: wrap;
}

.slide-counter {
  text-align: center;
  color: #dfe7df;
  font-size: .85rem;
  margin-top: .25rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 0;
  background: #b0bec5;
  padding: 0;
}

.dot.active { background: var(--green-700); }

.progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: var(--green-100);
  border: 1px solid var(--green-200);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-500), var(--green-700));
  transition: width .15s linear;
}

.note {
  margin-top: .2rem;
  padding-top: .35rem;
  border-top: 1px solid var(--green-200);
}

.note-wrap {
  margin-top: 0;
  position: relative;
}

.note-toggle-area {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  cursor: pointer;
}

.note-wrap-fade::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.3rem;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 85%);
  pointer-events: none;
}

.note.note-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

.note.note-expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
  white-space: pre-line;
}

.lernen-session-card {
  display: grid;
  gap: .9rem;
}

.lernen-session-image-btn {
  display: block;
  margin: 0 0 .8rem 0;
}

.lernen-antwort-block {
  margin: 0;
}

.lernen-antwort-block > summary {
  display: block;
  min-height: 44px;
  padding: .55rem .1rem;
  cursor: pointer;
}

.lernen-antwort-block > summary::-webkit-details-marker {
  display: none;
}

.lernen-antwort-block > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: .45rem;
  transition: transform .18s ease;
}

.lernen-antwort-block[open] > summary::before {
  transform: rotate(90deg);
}

.lernen-bewerten-form {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--green-200);
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

.note-structured-wrap {
  margin-top: .45rem;
}

.note-separator-top {
  border-top: 1px solid var(--green-200);
  margin-top: .85rem;
  padding-top: .65rem;
}

.note-section-block {
  margin-top: .6rem;
}

.note-section-title {
  margin: 0 0 .28rem;
  font-size: 1rem;
  font-weight: 650;
  color: var(--green-900);
}

.note-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 1px solid var(--green-200);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.note-table th,
.note-table td {
  border-bottom: 1px solid var(--green-200);
  padding: .4rem .5rem;
  vertical-align: top;
  text-align: left;
}

.note-table tr:last-child th,
.note-table tr:last-child td {
  border-bottom: 0;
}

.note-table th {
  width: 30%;
  font-size: .92rem;
  font-weight: 600;
  color: #2d4b34;
  background: #f7fbf7;
  text-align: left;
  vertical-align: top;
}

.note-table td {
  font-size: .92rem;
  vertical-align: top;
  line-height: 1.45;
  word-break: break-word;
}

.note-table th.note-key-empty {
  background: #fff;
  border-right: 1px solid var(--green-200);
}

.note-fallback {
  margin: .35rem 0 0;
}

.import-error {
  margin: .2rem 0;
  color: #b71c1c;
  font-weight: 600;
}

.import-warning {
  margin: .25rem 0 .75rem;
  color: #8d4e00;
  font-weight: 600;
}


.wiki-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .45rem .75rem;
  border-radius: 10px;
  border: 1px solid var(--green-200);
  background: linear-gradient(180deg, #f9fff9, #eef8ef);
  color: var(--green-900);
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
}

.wiki-link:hover {
  transform: translateY(-1px);
  border-color: var(--green-500);
  background: linear-gradient(180deg, #ffffff, #edf9ee);
  box-shadow: 0 4px 10px rgba(46, 125, 50, .12);
}

.wiki-link:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(46, 125, 50, .10);
}

.wiki-link:focus-visible {
  outline: 2px solid var(--green-500);
  outline-offset: 2px;
}

.wiki-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--green-100);
  font-size: .88rem;
  line-height: 1;
  flex: 0 0 auto;
}

.wiki-link-text {
  line-height: 1.2;
  word-break: break-word;
}

.pflanze-subtitle {
  display: block;
  margin-top: .15rem;
  font-size: .88em;
  font-weight: 500;
}

@media (max-width: 640px) {
  .topbar h1 { font-size: 1.1rem; }

  .chart-wrap {
    height: 220px;
  }

  .dashboard-presets {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-presets .btn:last-child {
    grid-column: 1 / -1;
  }

  .dashboard-today-stats {
    grid-template-columns: 1fr;
  }

  .lernstatus-grid,
  .lernstatus-counts {
    grid-template-columns: 1fr;
  }

  .ranking-list {
    padding-left: 1rem;
  }

  .lernen-session-image-btn {
    margin-bottom: 1rem;
  }

  .lernen-antwort-block > summary {
    min-height: 48px;
    padding: .65rem .1rem;
  }
}


.plant-extra-toggle {
  position: relative;
  margin-top: .55rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: .55rem;
  cursor: pointer;
}

.plant-extra-details {
  position: relative;
  transition: filter .22s ease, max-height .22s ease;
}

.plant-extra-toggle.note-wrap-fade .plant-extra-details {
  max-height: 3.8rem;
  overflow: hidden;
  filter: blur(2px);
}

.plant-extra-toggle.note-wrap-fade::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.6rem;
  background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,1));
  pointer-events: none;
}

.plant-extra-details.note-expanded {
  max-height: none !important;
  overflow: visible !important;
  filter: none !important;
}

.plant-extra-row {
  margin: 0 0 .35rem 0;
  line-height: 1.35;
  word-break: break-word;
}

.plant-extra-label {
  font-weight: 600;
}

/* Titel responsive umbrechen */
.topbar-title {
  line-height: 1.2;
}

@media (max-width: 640px) {
  .plant-counter {
    display: block;
    margin-top: 2px;
    font-size: 0.9em;
  }
}


  .xlsx-import-card {
    padding: 1.1rem 1.2rem;
  }

  .xlsx-import-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
  }

  .xlsx-import-section {
    display: flex;
    flex-direction: column;
    gap: .45rem;
  }

  .xlsx-import-label {
    font-weight: 700;
    color: var(--brand-dark, #1d5e20);
  }

  .xlsx-import-help {
    margin: 0;
  }

  .xlsx-import-option-row {
    padding: 1rem 1.1rem;
    border: 1px solid rgba(76, 124, 60, 0.18);
    border-radius: 14px;
    background: rgba(76, 124, 60, 0.05);
  }

  .xlsx-import-checkbox-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: .85rem;
    cursor: pointer;
    margin: 0;
    font-weight: 600;
    line-height: 1.45;
    color: var(--brand-dark, #1d5e20);
  }

  .xlsx-import-checkbox-label input[type="checkbox"] {
    margin: 0;
    flex: 0 0 auto;
    width: 1.05rem;
    height: 1.05rem;
    transform: none;
  }

  .xlsx-import-checkbox-text {
    display: inline-block;
    max-width: 42rem;
  }

  .xlsx-import-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
  }

  .xlsx-import-rules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .85rem;
    margin-top: .75rem;
  }

  .xlsx-rule-item {
    padding: .9rem 1rem;
    border-radius: 14px;
    background: rgba(76, 124, 60, 0.05);
    border: 1px solid rgba(76, 124, 60, 0.14);
  }

  .xlsx-rule-item strong {
    display: block;
    margin-bottom: .3rem;
    color: var(--brand-dark, #1d5e20);
  }

  .xlsx-rule-item p {
    margin: 0;
  }

  @media (max-width: 640px) {
    .xlsx-import-actions {
      flex-direction: column;
    }

    .xlsx-import-actions .btn,
    .xlsx-import-actions a.btn {
      width: 100%;
      text-align: center;
    }

    .xlsx-import-checkbox-label {
      align-items: flex-start;
      gap: .7rem;
    }

    .xlsx-import-checkbox-label input[type="checkbox"] {
      margin-top: .15rem;
    }

    .xlsx-import-checkbox-text {
      max-width: none;
    }
  }