/* Skalierung für Ausdruck: Seite nutzt volle A4-Breite, Höhe automatisch */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }
  #page-content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    page-break-after: avoid;
  }
  .notes-canvas, #notes-canvas {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: #fff !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .notes-card {
    max-width: 100% !important;
    box-sizing: border-box !important;
    background: #fff !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }
}
/* Druck-Styles: Blende Sidebar, Header und Footer beim Drucken aus */
@media print {
  aside#sidebar,
  #sidebar,
  header,
  #sidebar-footer,
  #toggle-sidebar {
    display: none !important;
  }
  #page-content {
    margin-left: 0 !important;
    width: 100vw !important;
    box-shadow: none !important;
  }
  body, html, #app, main {
    background: #fff !important;
    box-shadow: none !important;
  }
  button, input, textarea, form {
    display: none !important;
  }
}
/* Abstand für Links unter Buttons oder Formularen */
form + a,
form ~ a,
button + a,
.form-actions + a,
form + div > a,
a.spaced-link {
  display: inline-block;
  margin-top: 18px;
}
body { font-family: Arial, sans-serif; margin: 0; background: #f4f4f4; }
/* App-Container nimmt volle Höhe, max. Breite bleibt */
#login-container {
  max-width: 400px;
  margin: 40px auto;
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 2px 8px #0001;
}
#app {
  width: 100vw;
  min-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
}
header { display: flex; justify-content: space-between; align-items: center; }
main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100vw;
  gap: 0;
  position: relative;
}

main {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100vw;
  gap: 0;
}
aside {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
  transition: transform 0.2s, box-shadow 0.2s;
  background: #f8f9fb;
  box-shadow: 2px 0 8px #0001;
  z-index: 11;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 0 8px 8px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#sidebar-footer {
  margin-top: auto;
  padding: 16px 0 50px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#sidebar.sidebar-collapsed {
  transform: translateX(-240px);
  box-shadow: none;
  pointer-events: none;
}

#toggle-sidebar {
  display: inline-block;
  background: #1976d2;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 1.1em;
  box-shadow: 0 2px 8px #0002;
  cursor: pointer;
  transition: background 0.2s;
  margin-right: 8px;
  margin-left: 0;
  vertical-align: middle;
}
#toggle-sidebar:hover {
  background: #125ea2;
}

@media (max-width: 900px) {
  aside {
    position: absolute;
    left: 0;
    top: 72px;
    height: calc(100vh - 72px);
    max-height: 100vh;
    border-radius: 0 8px 8px 0;
  }
}
#pages-list { list-style: none; padding: 0; }
#pages-list li { padding: 6px 0; cursor: pointer; }
#pages-list li.selected { font-weight: bold; color: #1976d2; }
#page-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  margin-left: 220px;
  transition: margin-left 0.2s;
}
#sidebar.sidebar-collapsed + #page-content {
  margin-left: 0;
}
.notes-canvas, #notes-canvas {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  background: #f3f6fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: auto;
  box-sizing: border-box;
}
.notes-card {
  position: absolute;
  min-width: 120px;
  min-height: 40px;
  background: #f9f9f9;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 2px 8px #0001;
  padding: 12px;
  cursor: move;
  user-select: none;
}
.notes-card img {
  display: block;
  margin-top: 8px;
  border-radius: 4px;
}
.img-resize-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  background: rgba(25,118,210,0.8);
  border-radius: 3px;
  cursor: nwse-resize;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  box-shadow: 0 1px 3px #0002;
  transition: background 0.2s;
}
.img-resize-handle:hover {
  background: #1976d2;
}
.note-actions { position: absolute; top: 8px; right: 8px; }
button { background: #1976d2; color: #fff; border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
button:hover { background: #125ea2; }
input, textarea { width: 100%; margin-bottom: 8px; padding: 6px; border-radius: 4px; border: 1px solid #ccc; }
/* Inline-Editing: Textarea in Notizkarte */
.notes-card textarea {
  resize: both !important;
  min-width: 80px;
  min-height: 32px;
  max-width: 100%;
  max-height: 400px;
  box-sizing: border-box;
  font: inherit;
  background: #fffbe7;
  border: 1px solid #1976d2;
  border-radius: 4px;
  padding: 4px;
  outline: none;
  z-index: 1200;
}
/* Notizkarte: Textauswahl erlauben, aber nicht beim Draggen */
.notes-card {
  user-select: text;
}
