:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #687481;
  --line: #dbe2ea;
  --panel: #ffffff;
  --soft: #f4f7f8;
  --brand: #00a6c8;
  --brand-dark: #087b99;
  --accent: #f6c044;
  --shadow: 0 16px 40px rgba(18, 31, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.search-wrap {
  width: min(420px, 42vw);
}

input[type="search"] {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 166, 200, 0.16);
}

.shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 24px;
  padding: 24px 32px 40px;
}

.sidebar {
  position: sticky;
  top: 105px;
  align-self: start;
  max-height: calc(100vh - 129px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar-head,
.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.category-nav {
  display: grid;
  gap: 4px;
  padding: 8px;
}

.category-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

.category-button:hover,
.category-button.active {
  background: #e8f6f9;
}

.category-button span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 26px;
  padding: 2px 7px;
  color: var(--brand-dark);
  background: #dff4f8;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.content {
  min-width: 0;
}

.summary {
  margin-bottom: 18px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
}

.summary button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--brand-dark);
  background: #e8f6f9;
  border: 1px solid #bee8f0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.asset-card {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(18, 31, 44, 0.04);
}

.thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e9eef2;
  border: 0;
  cursor: pointer;
}

.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  color: #fff;
  background: var(--brand-dark);
  border-radius: 8px;
  font-size: 18px;
  font-weight: 800;
}

.video-icon {
  background: #17212b;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.18);
  font-size: 30px;
  padding-left: 4px;
}

.type-pill {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  color: #fff;
  background: rgba(23, 33, 43, 0.78);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.asset-info {
  padding: 12px;
}

.asset-name {
  min-height: 40px;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.asset-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.asset-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.asset-meta a,
.preview-footer a {
  color: var(--brand-dark);
  font-weight: 700;
  text-decoration: none;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.preview-dialog {
  width: min(1100px, calc(100vw - 36px));
  padding: 0;
  overflow: hidden;
  background: #0d1319;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-dialog::backdrop {
  background: rgba(8, 13, 18, 0.72);
}

.close-preview {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 38px;
  height: 38px;
  color: #fff;
  background: rgba(0, 0, 0, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}

#previewBody {
  display: grid;
  place-items: center;
  min-height: 55vh;
}

#previewBody img,
#previewBody video {
  display: block;
  max-width: 100%;
  max-height: 82vh;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  color: #d9e5ec;
  background: #111a22;
  overflow-wrap: anywhere;
  font-size: 14px;
}

#previewCaption {
  min-width: 0;
}

.preview-footer a {
  flex-shrink: 0;
  padding: 7px 12px;
  color: #091018;
  background: var(--accent);
  border-radius: 6px;
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    display: grid;
    padding: 18px;
  }

  .search-wrap {
    width: 100%;
  }

  .shell {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .category-nav {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 23px;
  }

  .summary {
    align-items: stretch;
    flex-direction: column;
  }

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