:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #d9dde3;
  --text: #1f2933;
  --muted: #667085;
  --brand: #1769aa;
  --brand-soft: #e8f2fb;
  --shadow: 0 8px 24px rgba(20, 32, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
}

#siteSubtitle,
#categoryDesc,
.item-meta,
.empty {
  color: var(--muted);
}

#searchInput {
  width: min(420px, 44vw);
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 16px;
  background: #fff;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 80px);
}

.sidebar {
  padding: 18px;
  background: #fbfcfd;
  border-right: 1px solid var(--line);
}

.sidebar-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-button,
#showAllButton {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

.category-button {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
}

.category-button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: #0d4f82;
  font-weight: 700;
}

.content {
  padding: 22px;
}

.content-head {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.content-head h2 {
  font-size: 24px;
  margin-bottom: 4px;
}

#showAllButton {
  padding: 0 16px;
  white-space: nowrap;
}

.folder-list {
  display: grid;
  gap: 16px;
}

.folder {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.folder-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.folder-header h3 {
  font-size: 18px;
}

.folder-toggle {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 18px;
}

.folder-body {
  display: none;
  padding: 14px;
}

.folder.open .folder-body {
  display: block;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.item-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.item-card:hover,
.item-card:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.item-type {
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0f3;
  color: #425466;
  font-size: 13px;
}

.item-title {
  font-size: 17px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.item-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

dialog {
  width: min(960px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.close-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

#viewerContent {
  padding: 58px 18px 18px;
}

#viewerContent img,
#viewerContent video {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #000;
  border-radius: 6px;
}

.viewer-text {
  white-space: pre-wrap;
  line-height: 1.8;
  font-size: 17px;
}

.viewer-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--brand);
  font-weight: 700;
}

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

  #searchInput {
    width: 100%;
  }

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .category-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .category-button {
    text-align: center;
    font-size: 14px;
  }

  .content {
    padding: 14px;
  }

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

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