:root{
  --bg: #0b0f14;
  --panel: #0f1720;
  --muted: #9aa6b2;
  --accent: #60a5fa;   /* helles Blau für Akzente */
  --accent-2: #3b82f6; /* kräftigeres Blau */
  --tile: #0d1115;
  --glass: rgba(255,255,255,0.03);
  --glass-2: rgba(255,255,255,0.02);
  --radius: 12px;
  --gap: 12px;
  --shadow: 0 6px 18px rgba(0,0,0,0.6);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color-scheme: dark;
  color: #e6eef3;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background: linear-gradient(180deg, var(--bg) 0%, #071019 100%);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  font-size:15px;
}

/* Demo banner */
.demo-banner{
  background: var(--accent);
  color: #fff;
  padding: 12px 18px;
  text-align: center;
  font-size: 1.05em;
  font-weight: 600;
  letter-spacing: 0.4px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}
.demo-banner .demo-banner-link{
  color: #fff;
  text-decoration: underline;
  font-weight: 700;
}

/* Demo button on login page styled like primary button */
.demo-btn{
  display:inline-block;
  padding:8px 12px;
  border-radius:8px;
  border:none;
  background: var(--accent);
  color:#fff;
  cursor:pointer;
  text-decoration:none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: background .2s ease, transform .08s ease;
}
.demo-btn:hover{ background: var(--accent-2); }
.demo-btn:active{ transform: translateY(1px); }

/* Auth (login/register) styles */
.auth-page{
  min-height:70vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.auth-container{
  width:100%;
  max-width:440px;
  background: var(--glass-2);
  padding:22px;
  border-radius:12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}
.auth-title{ margin:0 0 12px 0; }
.auth-fields{ display:flex; flex-direction:column; gap:10px; }
.auth-input{
  padding:10px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,0.06);
  background:transparent;
  color:inherit;
}
.auth-actions{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.auth-register{ color:var(--muted); align-self:center; margin-left:auto; }

/* Inline feedback messages */
.form-alert{
  background: rgba(255, 86, 86, 0.12);
  color: #ff8a8a;
  border: 1px solid rgba(255, 86, 86, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95em;
}
.form-success{
  background: rgba(16, 185, 129, 0.12);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95em;
}

#app{
  display:flex;
  flex-direction:column;
  min-height:100vh;
}

/* Corner button (top-left) */
.corner-btn{
  position: fixed;
  top: 12px;
  left: 12px;
  width: 54px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  text-decoration: none;
  outline: none;
}
.corner-btn svg{ display:block }
.corner-btn:focus{ outline: 2px solid rgba(59,130,246,0.4); outline-offset: 3px; }

/* topbar */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 18px;
  background: linear-gradient(90deg, rgba(255,255,255,0.01), transparent);
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.logo{
    margin:0;
    font-size:18px;
    letter-spacing:0.6px
}

.controls{
    display:flex;
    gap:10px;
    align-items:center
}

.controls input{
  padding:8px 10px;
  border-radius:10px;
  background:var(--glass);
  border:1px solid rgba(255,255,255,0.03);
  color:inherit
}

.pin-area{
  display:flex;
  gap:6px;
  align-items:center
}

.pin-area input{
  width:90px
}

/* layout */
.layout{
  display:flex;
  gap:14px;
  padding:18px;
  align-items:stretch;
}

.sidebar{
  width:240px;
  min-width:160px;
  background:var(--panel);
  border-radius:var(--radius);
  padding:12px;
  box-shadow:var(--shadow);
  /* let sidebar fill the layout height and scroll internally */
  height:auto;
  align-self:stretch;
  display:flex;
  flex-direction:column;
  overflow:auto;
}

/* ensure main content also scrolls if needed */
.content{
  flex:1 1 auto;
  min-width:0;
  overflow:auto;
}

#meta{
  display:flex;
  justify-content:flex-end
}

.admin-panel{
  background:linear-gradient(180deg,var(--glass),transparent);
  padding:12px;
  border-radius:10px;
  margin-bottom:12px;
  border:1px solid rgba(59,130,246,0.18);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12) inset;
}

.admin-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:10px
}

.admin-grid input,
.admin-grid select{
  width:100%;
  padding:8px;
  border-radius:8px;
  background:transparent;
  border:1px solid rgba(255,255,255,0.04);
  color:inherit
}

/* folders and tiles */
.folders{
  display:grid;
  /* max 3 columns, each at least 240px and grow equally */
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap:12px;
}

.folder{
  background: linear-gradient(180deg, rgba(13,17,21,0.6), rgba(10,13,18,0.6));
  padding:12px;
  border-radius:12px;
  border:1px solid rgba(59,130,246,0.08);
  transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  /* entfernt: max-height / overflow hidden — Kategorie wächst mit Inhalt */
  max-height: none;
  min-height: 140px;
  overflow: visible;
  box-shadow: 0 6px 18px rgba(3,8,20,0.6);
}

.folder:hover{
  transform:translateY(-6px);
  box-shadow:0 24px 60px rgba(14,36,80,0.6);
  /* intensivere Rahmenfarbe beim Hover */
  border-color: rgba(59,130,246,0.22);
}

/* leicht hervorgehobene Kopfzeile der Kategorie */
.folder 
.folder-head{
  background: linear-gradient(90deg, rgba(59,130,246,0.02), transparent);
  padding:4px 8px; /* weniger oben/unten, Titel sitzt höher */
  border-radius:8px;
  margin:-2px -4px 8px -4px; /* reduziertes top-offset */
  align-items:center;
  display:flex;
  gap:8px;
}

/* Kategorie-Titel enger nach oben rücken */
.folder .folder-head h3,
.folder h3 {
  margin:4px 0 6px 0;
  line-height:1.1;
  font-size:1.05rem;
}

/* Fokus-Rahmen für Tastaturnavigation */
.folder:focus-within,
.folder:focus {
  outline: 2px solid rgba(59,130,246,0.12);
  outline-offset: 4px;
}

.folder 
.sublist{
  margin-top:8px;
  padding-left:6px
}

.tiles{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:12px
}

.tile{
  background:var(--glass-2);padding:12px;border-radius:10px;min-width:170px;max-width:320px;
  border:1px solid rgba(255,255,255,0.02);box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  transition:transform .12s ease; cursor:pointer; display:flex;flex-direction:column;gap:6px;
}
.tile:hover{
  transform:translateY(-6px)
}

.tile h4{
  margin:0;
  font-size:15px
}

.tile p{
  margin:0;
  color:var(--muted);
  font-size:13px
}

/* make the content area inside folder scrollable (sublist + tiles) */
.folder > .sublist,
.folder > .tiles {
  overflow: visible;
  /* allow header (.folder-head) room, use remaining space heuristically */
  max-height: none;
  padding-right: 6px; /* breathing room for scrollbar */
}

/* subcategories: collapsible + clearer style */
.sublist{
  margin-top:8px;
  padding-left:6px;
  display:flex;
  flex-direction:column;
  gap:8px
}

.subcat{
  border-left: 2px solid rgba(255,255,255,0.03);
  padding-left:10px;
  border-radius:8px;
  overflow:hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
}

.subcat-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:8px;
  cursor:pointer;
  user-select:none;
  color:var(--accent);
  font-weight:600;
}

.subcat-head .title{
  color:var(--accent-2);
  font-weight:700
}

.subcat-head .muted{
  color:var(--muted); 
  font-weight:400
}

.subcat .caret{
  transition: transform .18s ease;
  color:var(--muted);
  font-size:14px;
}

.subcat.expanded .caret{ 
  transform: rotate(90deg); 
  color:var(--accent) 
}

/* tiles inside subcategory: collapsed/expanded */
.subcat-tiles{
  transition: max-height .22s ease, opacity .18s ease, padding .18s ease;
  overflow:hidden;
  padding:0 12px;
}
.subcat-tiles.collapsed{
  max-height:0;
  opacity:0;
  padding-top:0;
  padding-bottom:0;
}
.subcat-tiles.expanded{
  max-height: 2000px; /* großzügig, damit Inhalte sichtbar werden */
  opacity:1;
  padding-top:12px;
  padding-bottom:12px;
}

/* make tiles inside subcats visually separated */
.subcat .tile{ 
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
   border:1px solid rgba(255,255,255,0.03) 
}

/* clickable affordance */
.subcat-head:hover{
  background:rgba(255,255,255,0.01)
}

/* highlight flash when a category is clicked */
@keyframes flashHighlight {
  0% { box-shadow: 0 0 0 0 rgba(59,130,246,0.00); background: transparent; }
  20% { box-shadow: 0 8px 30px rgba(59,130,246,0.45); background: rgba(59,130,246,0.06); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.00); background: transparent; }
}

.folder.flash {
  animation: flashHighlight 1200ms ease;
  border-radius: var(--radius);
}

/* sidebar category list items: larger hit area + clearer look */
.sidebar .cat {
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:10px;
  border-radius:10px;
  cursor:pointer;
  transition: background .12s ease, transform .12s ease;
}

.sidebar .cat:hover {
  background: linear-gradient(90deg, rgba(255,255,255,0.02), transparent);
  transform: translateY(-2px);
}

.sidebar .cat .cat-head { 
  display:flex; 
  align-items:center; 
  justify-content:space-between; 
  gap:8px; width:100%; 
}

.sidebar .cat .cat-head strong { 
  font-size:14px;
  display:block; 
}

.sidebar .cat .cat-head .muted {
  font-size:12px;
   color:var(--muted); 
}

/* show subcategories in sidebar with indentation and larger hitbox */
.sidebar .sublist-inline {
  margin-top:6px;
  display:flex;
  flex-direction:column;
  gap:6px;
  padding-left:6px;
}

.sidebar .subitem {
  padding:8px;
  padding-left:12px;
  border-radius:8px;
  color:var(--muted);
  font-size:13px;
  cursor:pointer;
  display:block;
  width:100%;
  transition: background .12s ease, color .12s ease;
}

.sidebar .subitem:hover {
  background: rgba(255,255,255,0.02);
  color:var(--accent);
}

/* flash for subcategories when clicked from sidebar */
.subcat.flash {
  animation: flashHighlight 3000ms ease;
  border-radius:8px;
}

/* nicer scrollbars (WebKit) */
.sidebar::-webkit-scrollbar,
.folder > .sublist::-webkit-scrollbar,
.folder > .tiles::-webkit-scrollbar,
.subcat-tiles::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.sidebar::-webkit-scrollbar-track,
.folder > .sublist::-webkit-scrollbar-track,
.folder > .tiles::-webkit-scrollbar-track,
.subcat-tiles::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.folder > .sublist::-webkit-scrollbar-thumb,
.folder > .tiles::-webkit-scrollbar-thumb,
.subcat-tiles::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(96,165,250,0.22), rgba(59,130,246,0.18));
  border-radius: 999px;
  border: 2px solid rgba(11,15,20,0.0);
}

/* Firefox scrollbar */
.sidebar,
.folder > .sublist,
.folder > .tiles,
.subcat-tiles {
  scrollbar-width: thin;
  scrollbar-color: rgba(96,165,250,0.28) transparent;
}

/* responsive */
@media (max-width:1100px){
  .folders{
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}
@media (max-width:900px){
  .layout{
    flex-direction:column;
    padding:12px
  }
  
  .sidebar{
    width:100%;
    height:auto;
    order:2
  }
  /* mobile: nur eine Kategorie pro Reihe; erlauben, dass Zeilen mit Inhalt wachsen */
  .folders{
    order:1; 
    grid-template-columns: 1fr; 
    grid-auto-rows: auto; 
  }
  /* entferne feste Höhen, damit Folder mit Inhalt mitwächst */
  .folder{ 
    max-height: none; 
    min-height: 140px; 
  }

  .folder > .sublist, .folder > .tiles { 
    max-height: none; 
  }
  
  .subcat-tiles { 
    max-height: none; 
  }
  /* Behalte die mobil-spezifische Optik */
  .folder{
    border: 2px solid rgba(59,130,246,0.30);
    box-shadow: 0 18px 50px rgba(14,36,80,0.55);
    transform: none;
  }

  .folder .folder-head{
    padding:8px 10px;
    background: linear-gradient(90deg, rgba(59,130,246,0.03), transparent);
  }

  .folder:focus-within,
  .folder:focus {
    outline: 3px solid rgba(59,130,246,0.16);
    outline-offset: 3px;
  }
}

/* mobile sidebar: hidden by default, slides in as overlay */
.sidebar-toggle{
  display:none; /* shown only on small screens via media query */
  background:transparent;
  border:1px solid rgba(255,255,255,0.04);
  color:inherit;
  padding:8px 10px;
  border-radius:8px;
  cursor:pointer;
  font-size:18px;
  line-height:1;
}

/* backdrop for mobile sidebar */
#sidebar-backdrop{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.45);
  z-index:40;
}

/* override for small screens: make sidebar an offcanvas panel */
@media (max-width:900px){
  .sidebar{
    /* slide-in panel */
    position:fixed;
    left:0;
    top:0px; /* aligns under topbar */
    bottom:0;
    width:80%;
    max-width:340px;
    transform:translateX(-110%);
    transition: transform .26s ease;
    z-index:50;
    margin:0;
    border-radius:0 12px 12px 0;
    box-shadow: 0 30px 80px rgba(2,6,23,0.8);
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open{
    transform:translateX(0);
  }

  /* show toggle button in topbar */
  .sidebar-toggle{ 
    display:inline-flex; 
    align-items:center; 
    justify-content:center; 
  }

  /* ensure layout main content is full width behind overlay */
  .layout{ 
    padding-left:18px; 
    padding-right:18px; 
  }

  /* backdrop visible when sidebar open (JS toggles display:block) */
  #sidebar-backdrop.show{ 
    display:block; 
  }

  /* ensure sidebar internal scroll still works */
  .sidebar{ 
    overflow:auto; 
  }
}

/* hidden helper */
.hidden{
  display:none
}

/* small footer */
.footer{
  padding: 12px 18px;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
}

.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.footer-link svg {
  width: 16px;
  height: 16px;
}

.footer-link:hover {
  color: var(--accent);
}

.footer-separator {
  color: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

@media (max-width: 600px) {
  .footer-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
  }
  
  .footer-link {
    font-size: 12px;
  }
}

/* Legal pages styling */
.legal-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px;
}

.legal-content {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.legal-content h1 {
  color: var(--accent);
  margin-top: 0;
  margin-bottom: 30px;
  font-size: 32px;
}

.legal-content h2 {
  color: #e6eef3;
  margin-top: 30px;
  margin-bottom: 15px;
  font-size: 24px;
}

.legal-content h3 {
  color: #e6eef3;
  margin-top: 20px;
  margin-bottom: 12px;
  font-size: 18px;
}

.legal-content h4 {
  color: var(--muted);
  margin-top: 15px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 600;
}

.legal-content p {
  line-height: 1.7;
  margin-bottom: 15px;
  color: #d1dce6;
}

.legal-content ul {
  line-height: 1.7;
  margin-bottom: 15px;
  color: #d1dce6;
  padding-left: 25px;
}

.legal-content a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

.legal-content a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.back-link {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.back-link a:hover {
  color: var(--accent-2);
  transform: translateX(-4px);
}

@media (max-width: 768px) {
  .legal-content {
    padding: 25px;
  }
  
  .legal-content h1 {
    font-size: 26px;
  }
  
  .legal-content h2 {
    font-size: 20px;
  }
}
