:root {
  --bg: #f6f8f4;
  --panel: #ffffff;
  --text: #17201b;
  --muted: #66736b;
  --line: #dce4dc;
  --line-strong: #becabe;
  --green: #245b43;
  --green-dark: #173d2e;
  --teal: #11737a;
  --amber: #a66321;
  --focus: #2d7ff9;
  --shadow: 0 18px 50px rgba(23, 32, 27, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 52px) 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.06;
  letter-spacing: 0;
}

.source-link,
.download-list,
.dataset-tab,
#clearSearch {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--green-dark);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.source-link,
.download-list,
#clearSearch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

.source-link:hover,
.download-list:hover,
.dataset-tab:hover,
#clearSearch:hover {
  border-color: var(--green);
  color: var(--green);
}

.layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 22px;
  width: min(1480px, calc(100% - 36px));
  margin: 22px auto 36px;
}

.sidebar,
.browser {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  align-self: start;
  padding: 16px;
  position: sticky;
  top: 18px;
}

.dataset-tabs {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.dataset-tab {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  text-align: left;
}

.dataset-tab[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 0 0 16px;
  border-top: 1px solid var(--line);
}

.stats div {
  display: grid;
  grid-template-columns: minmax(90px, 0.9fr) minmax(0, 1.1fr);
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.stats dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stats dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.download-list {
  width: 100%;
}

.browser {
  min-width: 0;
  overflow: hidden;
}

.browser-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.search-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#searchInput {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
}

#searchInput:focus,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(45, 127, 249, 0.25);
  outline-offset: 2px;
}

.status-line {
  min-height: 42px;
  padding: 12px 16px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.tree,
.search-results {
  min-height: 520px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding: 12px 10px 18px;
}

.tree-folder {
  margin: 2px 0;
}

.tree-folder > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  list-style: none;
  font-weight: 800;
}

.tree-folder > summary::-webkit-details-marker {
  display: none;
}

.tree-folder > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid var(--teal);
  transition: transform 0.15s ease;
}

.tree-folder[open] > summary::before {
  transform: rotate(90deg);
}

.tree-folder > summary:hover,
.file-row:hover,
.result-row:hover {
  background: #edf4ef;
}

.tree-children {
  margin-left: 17px;
  padding-left: 13px;
  border-left: 1px solid var(--line);
}

.count-pill {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-row,
.result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 32px;
  padding: 5px 8px;
  border-radius: 6px;
}

.file-link,
.result-link {
  min-width: 0;
  overflow: hidden;
  color: var(--green-dark);
  font-weight: 650;
  text-overflow: ellipsis;
  text-decoration: none;
  white-space: nowrap;
}

.file-link:hover,
.result-link:hover {
  color: var(--teal);
  text-decoration: underline;
}

.file-type {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-row {
  grid-template-columns: minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

.result-link {
  white-space: normal;
  overflow-wrap: anywhere;
}

.empty-state,
.error-state {
  padding: 24px 16px;
  color: var(--muted);
}

.error-state {
  color: #9d2b2b;
  font-weight: 700;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-actions {
    justify-content: flex-start;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .browser-toolbar {
    grid-template-columns: 1fr;
  }

  #clearSearch {
    justify-self: start;
  }

  .tree,
  .search-results {
    max-height: none;
  }
}
