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

:root {
  --bg:        #1a1a1a;
  --bg-sidebar: #242424;
  --bg-card:   #2d2d2d;
  --border:    #3a3a3a;
  --text:      #e0e0e0;
  --text-muted: #888;
  --accent:    #c0392b;
  --accent-hover: #e74c3c;
  --sidebar-w: 220px;
}

html, body { height: 100%; }

body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  overflow: hidden;
}

/* ── Sidebar ── */
#sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#live-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #555;
  transition: background .3s;
}
#live-indicator.connected { background: #27ae60; }
#live-indicator.flash     { background: var(--accent); }

#folder-tree {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 6px 0;
}

#folder-tree li {
  padding: 5px 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 4px;
  margin: 1px 6px;
  color: var(--text);
  transition: background .15s;
}
#folder-tree li:hover   { background: rgba(255,255,255,.06); }
#folder-tree li.active  { background: var(--accent); color: #fff; }

#folder-tree .folder-icon { margin-right: 6px; font-style: normal; }

/* nested folders */
#folder-tree ul { list-style: none; }
#folder-tree ul li { padding-left: 26px; }

/* ── Main area ── */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#breadcrumb {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#gallery {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  align-content: start;
}

#empty-state {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}
#empty-state.visible { display: flex; }

.img-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  display: flex;
  flex-direction: column;
}
.img-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.img-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #222;
  padding: 4px;
}

.img-card figcaption {
  padding: 4px 6px;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--border);
}

/* ── Lightbox ── */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: zoom-out;
}
#lightbox[hidden] { display: none; }

#lightbox-img {
  max-width: 90vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  cursor: default;
}

#lightbox-caption {
  margin-top: 12px;
  color: #ccc;
  font-size: 13px;
}

#lightbox-close {
  position: absolute;
  top: 16px; right: 20px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}
#lightbox-close:hover { color: #fff; }

/* ── Scrollbar ── */
::-webkit-scrollbar         { width: 6px; }
::-webkit-scrollbar-track   { background: transparent; }
::-webkit-scrollbar-thumb   { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }
