:root {
  --bg: #1f2227;
  --panel: #252a31;
  --panel-soft: #2b3038;
  --text: #d6d9df;
  --muted: #9aa0aa;
  --accent: #4e8ef7;
  --border: #3a404a;
  --card-h: 188px;
  --grid-gap: 14px;
  --grid-pad: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr 320px;
}
.mobile-action,.mobile-close {
  display: none;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
}
.left-panel,.right-panel { background: var(--panel); }
.left-panel { border-right: 1px solid var(--border); }
.right-panel { border-left: 1px solid var(--border); padding: 16px; overflow: auto; }
.brand { padding: 16px; font-weight: 600; border-bottom: 1px solid var(--border); }
.folder-tree { padding: 12px; overflow: auto; max-height: calc(100vh - 64px); }
.tree-item,.tree-library-header,.tree-subitem {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.tree-item:hover,.tree-item.is-active,.tree-subitem:hover,.tree-subitem.is-active,.tree-library-header:hover {
  background: var(--panel-soft);
  color: var(--text);
}
.tree-library-group { margin-bottom: 6px; border: 1px solid #303641; border-radius: 8px; overflow: hidden; }
.tree-library-header { display: flex; justify-content: space-between; align-items: center; font-weight: 600; border-radius: 0; }
.tree-chevron { color: var(--muted); font-size: 12px; }
.tree-library-content { padding: 6px; }
.tree-subitem { padding: 7px 10px; border-radius: 6px; color: var(--muted); }
.tree-subitem.all { font-weight: 600; color: var(--text); }
.tree-folder-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
.tree-folder-toggle,.tree-folder-spacer {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 22px;
  text-align: center;
  padding: 0;
  cursor: pointer;
  border-radius: 4px;
}
.tree-folder-toggle:hover { background: var(--panel-soft); color: var(--text); }
.tree-folder-item {
  flex: 1;
  min-width: 0;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.center-panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar {
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  background: var(--panel);
}
.toolbar-main { flex: 1; min-width: 0; }
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}
.breadcrumb button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font: inherit;
}
.breadcrumb button:hover { color: var(--text); }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--text); }
.toolbar-filters { display: flex; gap: 8px; align-items: center; }
.search {
  flex: 1;
  min-width: 180px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
.control-select,.control-button {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
.control-button { cursor: pointer; }
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.link-button.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.tag-filters { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  border: 1px solid var(--border);
  background: #252b34;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.tag-chip.is-active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(78, 142, 247, 0.15);
}
.gallery-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}
.gallery-spacer { position: relative; min-height: 100%; }
.gallery-grid {
  padding: var(--grid-pad);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--grid-gap);
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}
.asset-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  height: var(--card-h);
}
.asset-card.is-selected { border-color: var(--accent); }
.thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  background: #353b45;
  display: block;
}
.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
.asset-name {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
h2 { margin: 0 0 12px; font-size: 16px; }
.detail-image {
  height: 170px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: #353b45;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  overflow: hidden;
}
.detail-image img { width: 100%; height: 100%; object-fit: contain; background: #1b1e22; }
.field { margin-bottom: 10px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.field input,.field textarea {
  width: 100%;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
}
.field textarea { min-height: 70px; resize: vertical; }
.meta-block {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: grid;
  gap: 6px;
  font-size: 12px;
}
.meta-block div { display: flex; justify-content: space-between; gap: 10px; }
.meta-block span { color: var(--muted); }
.meta-block strong { font-weight: 500; color: var(--text); font-size: 12px; }
.right-panel h2 { font-size: 14px; font-weight: 600; }
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 48px 64px 72px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform: scale(0.86);
  opacity: 0;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}
.lightbox.is-open .lightbox-image {
  transform: scale(1);
  opacity: 1;
}
.lightbox-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 1px solid #5b6270;
  background: #2a303a;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  z-index: 2;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  border: 1px solid #5b6270;
  background: rgba(42, 48, 58, 0.85);
  color: #fff;
  border-radius: 10px;
  font-size: 28px;
  cursor: pointer;
  z-index: 2;
}
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }
.lightbox-toolbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  z-index: 2;
}
.lightbox-caption {
  color: #d6d9df;
  font-size: 13px;
  max-width: min(60vw, 480px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #2a303a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.is-show { opacity: 1; }

@media (max-width: 900px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .left-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 80%;
    max-width: 340px;
    height: 100vh;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,0.35);
  }
  .left-panel.is-open { transform: translateX(0); }
  .right-panel { border-left: 0; border-top: 1px solid var(--border); }
  .mobile-action,.mobile-close { display: inline-block; }
  .mobile-close { margin: 0 12px 8px; width: calc(100% - 24px); }
  .toolbar { gap: 10px; height: auto; padding: 10px 12px; flex-wrap: wrap; }
  .toolbar-filters { width: 100%; flex-wrap: wrap; }
  .search { min-width: 120px; width: 100%; }
  .control-select { flex: 1; min-width: 120px; }
  .control-button { white-space: nowrap; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .gallery-viewport { min-height: 50vh; }
  .lightbox { padding: 56px 12px 80px; }
  .lightbox-nav { width: 36px; height: 52px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
}
