:root {
  --header-h: clamp(56px, 8vh, 80px);
  --sidebar-w: clamp(200px, 32vw, 320px);
  --brand-red: #c40000;
  --search-border: #cdd6e0;
  --btn-bg: #15b86a;
  --btn-bg-hover: #13a55e;
}

/* ───────── Reset ───────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, Helvetica, Arial, sans-serif;
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ───────── Header ───────── */
header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 3000;
}

#toggleTree {
  display: none;
  /* shown via media query */
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
}

/* ───────── Navigation button ───────── */
.nav-container {
  margin-left: auto;
}

#registerButton {
  background: var(--btn-bg);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s;
}

#registerButton:hover {
  background: var(--btn-bg-hover);
}

#registerButton i {
  font-size: 1rem;
}

/* ───────── Search block ───────── */
.search-container {
  flex: 1;
  max-width: 650px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-wrapper {
  flex: 1;
  position: relative;
  /* anchors dropdown */
}

.search-wrapper input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--search-border);
  border-radius: 4px;
  font-size: 0.95rem;
}

.search-wrapper input:hover,
.search-wrapper input:focus {
  border-color: var(--btn-bg);
  /* #15b86a */
  box-shadow: 0 0 0 2px rgba(21, 184, 106, 0.25);
  /* optional glow */
}

.search-container button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: var(--btn-bg);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.search-container button:hover {
  background: var(--btn-bg-hover);
}

.search-container button i {
  font-size: 0.95rem;
}

/* dropdown */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #ddd;
  border-top: none;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 2000;
}

.dropdown-menu div {
  padding: 6px 10px;
  cursor: pointer;
  color: #000;
}

.dropdown-item-active,
.dropdown-menu div:hover {
  background: #e5f3ff;
}

.dropdown-menu .no-results {
  padding: 10px;
  text-align: center;
  color: #666;
  font-style: italic;
  cursor: default;
}

.dropdown-menu .no-results:hover {
  background: transparent;
}

/* ───────── Title ───────── */
.title-container {
  margin-left: clamp(16px, 2vw, 32px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}

#landnumer-haus {
  font-size: clamp(1.25rem, 2.5vw, 1.5rem);
  font-weight: 600;
  color: var(--brand-red);
}

#landnumer-value {
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  font-weight: 600;
  color: var(--brand-red);
}

/* ───────── Sidebar ───────── */
#tree-container {
  flex: 0 0 var(--sidebar-w);
  max-width: var(--sidebar-w);
  overflow-y: auto;
  border-right: 1px solid #e0e0e0;
  background: #fafafa;
  max-height: calc(100vh - var(--header-h));
  transition: transform 0.25s ease;
}

#tree-container.hidden {
  display: none;
}

/* ───────── Viewer ───────── */
#pdf-container {
  flex: 1;
  min-height: 100%;
  display: flex;
}

#pdf-container iframe {
  border: none;
  width: 100%;
  height: 100%;
}

.pdf-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
}

.pdf-guide-content {
  text-align: center;
  color: #6c757d;
  max-width: 300px;
  padding: 2rem;
}

.pdf-guide-content i {
  margin-bottom: 1rem;
  opacity: 0.7;
}

.pdf-guide-content .fa-file-pdf {
  color: #dc3545;
}

.pdf-guide-content .fa-exclamation-triangle {
  color: #ffc107;
}

.pdf-guide-content h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #495057;
  font-weight: 600;
}

.pdf-guide-content p {
  font-size: 1rem;
  line-height: 1.5;
  margin: 0;
}

/* ───────── details tree ───────── */
details {
  border-bottom: 1px solid #ececec;
}

details summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 8px 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

details summary::before {
  content: "▶";
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}

details[open]>summary::before {
  content: "▼";
}

/* nested */
details details {
  border: none;
}

details details summary {
  font-weight: 500;
  padding-left: 26px;
}

details details summary::before {
  content: "►";
}

details details[open]>summary::before {
  content: "▼";
}

details a {
  display: block;
  padding: 4px 34px;
  text-decoration: none;
  color: #0366d6;
}

details a:hover {
  background: #f0f0f0;
}

/* ───────── Feedback ───────── */
#loading,
#empty-search {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 1rem;
  line-height: 1.4;
}

#loading {
  color: #cc071e;
}

/* ───────── Layout ───────── */
main {
  flex: 1;
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

/* ───────── Responsive ───────── */
@media (max-width: 1024px) {
  #tree-container {
    --sidebar-w: 280px;
  }
}

@media (max-width: 768px) {
  #toggleTree {
    display: block;
  }

  main {
    flex-direction: column;
  }

  #tree-container {
    order: 2;
    flex: 1 1 auto;
    max-width: none;
    border-right: none;
    border-top: 1px solid #e0e0e0;
  }

  #pdf-container {
    /* exact size of the slot */
    height: calc(100vh - var(--header-h));
    /* fills everything under header */
    /* or: height: 80vh;  choose the % you like */
    flex: 0 0 auto;
    /* stops flexbox from stretching it further */
    overflow: hidden;
    /* keeps internal viewer tidy */
  }
}

@media (max-width: 480px) {
  .search-container {
    max-width: none;
  }

  #landnumer-haus {
    font-size: 1.125rem;
  }

  #landnumer-value {
    font-size: 0.95rem;
  }

  .search-container button {
    padding: 8px 14px;
  }
}

/* ───────── Subtext styling ───────── */
.subtext {
  font-size: 0.8em;
  color: #666;
  font-style: italic;
  margin-top: 2px;
  line-height: 1.2;
}