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

img {
  border: none;
  margin: 0;
  padding: 0;
}

a {
  outline: none;
  text-decoration: none;
  color: #1f2937;
}

.clear {
  clear: both;
}

body {
  font-size: 13px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1f2937;
  background-color: #eef1f5;
  min-height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.folder-tree {
  width: 260px;
  background: #f6f8fb;
  border-right: 1px solid #c8cfd8;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.tree-header {
  padding: 8px 12px;
  background: #eef1f5;
  border-bottom: 1px solid #c8cfd8;
  font-weight: bold;
  font-size: 13px;
  color: #374151;
}

.tree-content {
  flex: 1;
  overflow-y: auto;
  padding: 5px 0;
}

.tree-node {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.tree-node li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-item {
  display: flex;
  align-items: center;
  padding: 3px 8px 3px 16px;
  cursor: pointer;
  color: #4b5563;
  font-size: 15px;
  transition: all 0.1s;
  user-select: none;
}

.tree-item:hover {
  background: #e4ebf4;
  color: #111;
}

.tree-item.active {
  background: #0066cc;
  color: #fff;
}

.tree-item .arrow {
  width: 16px;
  margin-right: 4px;
  font-size: 10px;
  display: inline-block;
  text-align: center;
  flex-shrink: 0;
}

.tree-item .icon {
  margin-right: 6px;
  font-size: 13px;
  display: inline-block;
  width: 18px;
  text-align: center;
}

.tree-children {
  margin-left: 18px;
  display: none;
}

.tree-children.open {
  display: block;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.top-bar {
  background: #eef2f7;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #c8cfd8;
  flex-shrink: 0;
}

.breadcrumbs {
  font-size: 14px;
  color: #1f2937;
}

.breadcrumb-count {
  font-size: 11px;
  color: #888;
  margin-left: 6px;
}

.year-strip {
  display: none;
}

/* Окно просмотра (превью и серии) — всегда тёмное */
.gallery-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #2a2a2a url('images/bg.jpg') repeat;
}

#gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.cat_item_wrap {
  cursor: pointer;
  transition: transform 0.2s ease;
  text-align: center;
}

.cat_item_wrap:hover {
  transform: translateY(-5px);
}

.cat_item {
  background: #555555;
  border: 1px solid #555;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.cat_item:hover {
  border-color: #888;
  box-shadow: 0 0 10px rgba(255,255,255,0.2);
}

.cat_item img {
  max-width: 90%;
  max-height: 90%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.cat_item_placeholder {
  color: #999;
  text-align: center;
  padding: 20px;
  font-size: 11px;
}

.cat_item_title {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: #f7f7f7 !important;
  line-height: 1.3;
  padding: 0 4px;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  flex-shrink: 0;
  border-top: 1px solid #c8cfd8;
  background: #eef2f7;
}

.pg-btn {
  background: #fff;
  border: 1px solid #b9c2cf;
  color: #4b5563;
  padding: 3px 8px;
  font-size: 10px;
  cursor: pointer;
  border-radius: 3px;
}

.pg-btn:hover {
  background: #e4ebf4;
  color: #111;
}

.pg-btn.active {
  background: #dbe5f1;
  color: #111;
  font-weight: bold;
  border-color: #8a94a3;
}

.pg-info {
  color: #8a94a3;
  font-size: 10px;
  margin: 0 6px;
  line-height: 22px;
}

/* 🖼️ ПРОСМОТР СЕРИИ — 50% ОТ ОРИГИНАЛА ПО БОЛЬШЕЙ СТОРОНЕ */
#gallery-grid.series-mode {
  display: block !important;
  text-align: center;
  font-size: 0;
  line-height: 0;
  padding: 10px;
}

#gallery-grid.series-mode img {
  display: inline-block;
  border: none;
  background: transparent;
  margin-right: 10px;
  margin-bottom: 10px;
  vertical-align: bottom;
  /* Размеры будут заданы через JS в пикселях */
}

#gallery-grid.series-mode img:last-child {
  margin-right: 0;
}

.series-image-caption {
  display: none;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #b9c2cf;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #8a94a3;
}

@media (min-width: 1200px) {
  #gallery-grid {
    padding: 0 40px;
  }
}