body {
  min-height: 100vh;
}

html,
body {
  overflow-x: hidden;
}

.notizen-main,
.notizen-main *,
.notizen-main *::before,
.notizen-main *::after {
  box-sizing: border-box;
}

.notizen-main {
  padding: 24px 18px 200px;
}

.notizen-seite {
  max-width: 1450px;
  margin: 0 auto;
}

.notizen-kopf {
  margin-bottom: 18px;
}

.notizen-kopf h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.7vw, 2.35rem);
}

.notizen-kopf p {
  margin: 10px 0 0;
  color: var(--text-muted);
}

.notizen-grid {
  display: grid;
  grid-template-columns: 250px 360px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 80px;
}

.notizen-karte {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  min-height: 560px;
}

.notizen-karte h2 {
  margin: 0;
  font-size: 1.05rem;
}

.ordner-kopf,
.liste-kopf,
.editor-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-titel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.editor-aktionen {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ordner-aktionen {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-back-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(59, 130, 246, 0.32);
  background: rgba(59, 130, 246, 0.16);
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}

.notiz-mini-btn,
.notiz-haupt-btn,
.notiz-aktion-btn {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-family: Inter, sans-serif;
}

.notiz-mini-btn {
  min-width: 34px;
  height: 34px;
  color: #0f172a;
  background: linear-gradient(135deg, #3399ff, #66d9ff);
}

.notiz-mini-btn.warnung-mini {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.notiz-haupt-btn {
  width: 100%;
  height: 42px;
  color: #0f172a;
  background: linear-gradient(135deg, #3399ff, #66d9ff);
  margin-bottom: 10px;
}

.cloud-btn {
  width: 100%;
  margin-bottom: 8px;
}

.cloud-status {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.notiz-aktion-btn {
  height: 38px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.notiz-aktion-btn.warnung {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
}

.schriftgroesse-dropdown {
  position: relative;
}

.schriftgroesse-toggle {
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.schriftgroesse-dropdown.offen .schriftgroesse-toggle {
  border-color: rgba(102, 217, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.18);
}

.schriftgroesse-pfeil {
  transition: transform 0.2s ease;
}

.schriftgroesse-dropdown.offen .schriftgroesse-pfeil {
  transform: rotate(180deg);
}

.schriftgroesse-menue {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 180px;
  padding: 7px;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: var(--bg-card);
  box-shadow: 0 14px 30px rgba(2, 8, 23, 0.45);
  display: grid;
  gap: 5px;
}

.schriftgroesse-menue[hidden] {
  display: none !important;
}

.export-dropdown {
  position: relative;
}

.export-dropdown.offen .export-toggle {
  border-color: rgba(102, 217, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.18);
}

.export-menue {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 35;
  min-width: 170px;
  padding: 7px;
  border-radius: 12px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: var(--bg-card);
  box-shadow: 0 14px 30px rgba(2, 8, 23, 0.45);
  display: grid;
  gap: 5px;
}

.export-menue[hidden] {
  display: none !important;
}

.export-option {
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  text-align: left;
  padding: 0 10px;
  font-family: Inter, sans-serif;
  font-weight: 600;
  cursor: pointer;
}

.export-option:hover {
  border-color: rgba(102, 217, 255, 0.45);
  background: rgba(51, 153, 255, 0.14);
}

.schriftgroesse-option {
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  text-align: left;
  padding: 0 10px;
  font-family: Inter, sans-serif;
  cursor: pointer;
}

.schriftgroesse-option:hover {
  border-color: rgba(102, 217, 255, 0.45);
  background: rgba(51, 153, 255, 0.14);
}

.schriftgroesse-option.aktiv {
  color: #0f172a;
  background: linear-gradient(135deg, #3399ff, #66d9ff);
  border-color: transparent;
  font-weight: 700;
}

.ordner-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ordner-liste li {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(148, 163, 184, 0.07);
  transition: 0.2s ease;
}

.ordner-liste li:hover {
  border-color: rgba(59, 130, 246, 0.35);
}

.ordner-liste li.aktiv {
  border-color: rgba(102, 217, 255, 0.7);
  background: rgba(51, 153, 255, 0.2);
}

.ordner-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ordner-zaehler {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.notizen-suche {
  width: 100%;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.notizen-suche:focus,
.editor-feld input:focus,
.editor-feld textarea:focus,
.notiz-editor:focus {
  outline: none;
  border-color: #66d9ff;
  box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.18);
}

.filter-reihe {
  margin-bottom: 10px;
}

.filter-reihe label {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.notizen-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 490px;
  overflow-y: auto;
}

.notizen-liste li {
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(148, 163, 184, 0.08);
  padding: 10px;
  cursor: pointer;
  transition: 0.2s ease;
}

.notizen-liste li:hover {
  border-color: rgba(102, 217, 255, 0.6);
}

.notizen-liste li.aktiv {
  border-color: rgba(102, 217, 255, 0.8);
  background: rgba(51, 153, 255, 0.18);
}

.notiz-listen-titel {
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pin-symbol {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  transform: rotate(18deg);
}

.pin-symbol::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1px;
  width: 12px;
  height: 7px;
  border-radius: 7px 7px 5px 5px;
  background: linear-gradient(135deg, #ef4444, #f87171);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.32);
}

.pin-symbol::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 6px;
  width: 2px;
  height: 10px;
  background: #fee2e2;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.18);
}

.notiz-listen-vorschau {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.notiz-listen-meta {
  margin-top: 7px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.keine-notiz {
  margin: 12px 0;
  color: var(--text-muted);
}

.editor-felder {
  display: grid;
  gap: 9px;
}

.editor-feld {
  display: grid;
  gap: 6px;
}

.editor-feld label {
  font-size: 0.87rem;
  color: var(--text-muted);
}

.editor-feld input,
.editor-feld textarea {
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: Inter, sans-serif;
  font-size: 0.95rem;
}

.editor-feld textarea {
  min-height: 360px;
  resize: vertical;
  line-height: 1.5;
}

.notiz-editor {
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: Inter, sans-serif;
  font-size: 0.95rem;
  min-height: 360px;
  line-height: 1.5;
  overflow-y: auto;
  white-space: pre-wrap;
}

.notiz-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}

.editor-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-tag {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.editor-checkbox {
  position: relative;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.editor-checkbox:hover {
  border-color: rgba(102, 217, 255, 0.55);
  background: rgba(51, 153, 255, 0.16);
}

.editor-checkbox input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.editor-checkbox-box {
  position: relative;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.36);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.editor-checkbox-box::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border-right: 2px solid transparent;
  border-bottom: 2px solid transparent;
  transform: rotate(45deg);
}

.editor-checkbox-text {
  color: var(--text);
  font-weight: 600;
}

.editor-checkbox input:checked + .editor-checkbox-box {
  background: linear-gradient(135deg, #3399ff, #66d9ff);
  border-color: transparent;
}

.editor-checkbox input:checked + .editor-checkbox-box::after {
  border-color: #0f172a;
}

.editor-checkbox:has(input:checked) {
  background: rgba(51, 153, 255, 0.18);
  border-color: rgba(102, 217, 255, 0.7);
}

.editor-checkbox:has(input:focus-visible) {
  box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.18);
}

.editor-werkzeuge {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0;
}

.speicher-status {
  margin-top: 9px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 1220px) {
  .notizen-grid {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .editor-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 768px) {
  .notizen-main {
    padding-top: 16px;
    padding-bottom: 28px;
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
  }

  .notizen-seite {
    padding-inline: 2px;
    overflow-x: clip;
  }

  .editor-kopf {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .panel-titel {
    width: 100%;
    margin-right: 0;
  }

  .editor-aktionen {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-aktionen .notiz-aktion-btn,
  .editor-aktionen .export-dropdown {
    width: 100%;
    box-sizing: border-box;
  }

  .editor-aktionen .export-toggle {
    width: 100%;
    box-sizing: border-box;
  }

  .editor-aktionen .notiz-aktion-btn.warnung {
    grid-column: auto;
  }

  .notizen-grid {
    display: block;
  }

  .notizen-karte {
    min-height: 0;
    padding: 12px;
    display: none;
    overflow-x: hidden;
  }

  .notizen-karte.mobile-sichtbar {
    display: block;
  }

  .mobile-panel-inhalt {
    display: block;
  }

  .mobile-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .notizen-liste {
    max-height: 320px;
  }

  .schriftgroesse-toggle {
    min-width: 136px;
  }

  .schriftgroesse-menue {
    left: 0;
    right: auto;
    min-width: 168px;
  }

  .export-menue {
    position: absolute;
    left: 0;
    right: auto;
    top: calc(100% + 6px);
    bottom: auto;
    min-width: 170px;
    max-width: min(220px, calc(100vw - 36px));
    overflow-y: auto;
    padding: 9px;
  }

  .editor-feld textarea {
    min-height: 260px;
  }

  .editor-zeile {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .editor-checkbox {
    width: 100%;
    box-sizing: border-box;
  }

  .editor-werkzeuge {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .editor-werkzeuge .notiz-aktion-btn,
  .editor-werkzeuge .schriftgroesse-dropdown {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .schriftgroesse-toggle {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .notiz-editor {
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
  }
}

@media (max-width: 420px) {
  .notizen-main {
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
  }

  #navbar .navbar {
    padding: 8px 8px;
    gap: 6px;
  }

  #navbar .logo img {
    height: 36px;
  }

  #navbar .user-menu {
    margin-left: 4px;
  }

  #navbar .user-btn {
    width: 34px;
    height: 34px;
  }

  #navbar .menu-toggle {
    font-size: 24px;
    line-height: 1;
    padding: 2px 4px;
  }

  .editor-aktionen {
    grid-template-columns: 1fr;
  }

  .editor-aktionen .notiz-aktion-btn.warnung {
    grid-column: 1;
  }

  .editor-werkzeuge {
    grid-template-columns: 1fr;
  }

  .schriftgroesse-menue,
  .export-menue {
    max-width: calc(100vw - 24px);
  }

  .editor-feld input,
  .notiz-editor {
    width: 100%;
    min-width: 0;
  }
}

[data-theme="light"] .notizen-karte {
  background: #ffffff;
  border-color: rgba(59, 130, 246, 0.24);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .ordner-liste li,
[data-theme="light"] .notizen-liste li {
  background: #f8fbff;
  border-color: rgba(59, 130, 246, 0.22);
}

[data-theme="light"] .ordner-liste li.aktiv,
[data-theme="light"] .notizen-liste li.aktiv {
  background: rgba(102, 217, 255, 0.2);
}

[data-theme="light"] .notizen-suche,
[data-theme="light"] .editor-feld input,
[data-theme="light"] .editor-feld textarea,
[data-theme="light"] .notiz-editor {
  background: #f8fbff;
  color: #0f172a;
}

[data-theme="light"] .cloud-status {
  color: #475569;
}

[data-theme="light"] .mobile-back-btn {
  color: #1e293b;
  background: rgba(59, 130, 246, 0.08);
}
