:root {
  --bg: #f6f6f7;
  --bar: rgba(248, 248, 249, 0.94);
  --panel: #fff;
  --panel-soft: #fafafb;
  --border: #e2e2e5;
  --border-strong: #d6d6da;
  --text: #1c1d1f;
  --muted: #6e6e73;
  --muted-2: #8b8b91;
  --accent: #1e7afe;
  --accent-strong: #155dd4;
  --accent-soft: rgba(30, 122, 254, 0.1);
  --danger: #b3261e;
  --shadow: 0 18px 44px -18px rgba(20, 30, 50, 0.32);
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

a {
  text-decoration: none;
}

.catalog-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hdr {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 22px;
  height: 54px;
  padding: 0 24px;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
}

.hdr-left,
.hdr-right {
  display: flex;
  align-items: center;
  min-width: 230px;
}

.hdr-left {
  gap: 10px;
}

.hdr-right {
  gap: 8px;
  justify-content: flex-end;
  margin-left: auto;
}

.logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: linear-gradient(180deg, #2c8bff, #105fd6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 1px 2px rgba(20, 40, 80, 0.18);
}

.logo-square {
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.hdr-name {
  font-weight: 600;
  font-size: 14px;
}

.hdr-sub {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 1px;
}

.hdr-search {
  flex: 1;
  max-width: 720px;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.hdr-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 122, 254, 0.16);
}

.hdr-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.hdr-search input::placeholder {
  color: #9a9aa0;
}

.clear-btn {
  width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: #c7c7cc;
}

.clear-btn:hover {
  background: #a9a9b0;
}

.user-pill {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.icon-text-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 12.5px;
}

.icon-text-btn,
.btn.ghost {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
}

.icon-text-btn:hover,
.btn.ghost:hover {
  background: #f2f2f4;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #146cf0;
}

.filterbar {
  position: sticky;
  top: 54px;
  z-index: 50;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 24px;
  background: var(--panel-soft);
  border-bottom: 1px solid #e8e8eb;
}

.fb-left,
.fb-right {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.fb-left {
  flex-wrap: wrap;
}

.result-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.fbtn {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 12.5px;
  white-space: nowrap;
  max-width: 230px;
}

.fbtn:hover {
  background: #f3f3f5;
  border-color: #c7c7cc;
}

.fbtn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 122, 254, 0.14);
}

.fbtn.has-value {
  border-color: rgba(30, 122, 254, 0.36);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.fbtn.quiet {
  color: var(--muted);
  background: transparent;
}

.fbtn-label,
.fbtn-value {
  overflow: hidden;
  text-overflow: ellipsis;
}

.fbtn-value {
  color: var(--accent-strong);
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 24px 0;
  background: var(--panel-soft);
}

.filter-chip {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
  padding: 0 7px 0 9px;
  border-radius: 6px;
  border: 1px solid rgba(30, 122, 254, 0.25);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11.5px;
  font-weight: 500;
}

.filter-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover {
  position: fixed;
  z-index: 120;
  width: 280px;
  max-width: calc(100vw - 24px);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 14px 32px -10px rgba(20, 30, 50, 0.28), 0 2px 6px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.poplist {
  padding: 6px;
}

.pop-row {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 6px;
  text-align: left;
  color: var(--text);
}

.pop-row:hover {
  color: var(--accent-strong);
  background: rgba(30, 122, 254, 0.08);
}

.pop-row.selected {
  color: var(--accent-strong);
}

.pop-row svg:last-child {
  margin-left: auto;
}

.pop-divider {
  height: 1px;
  background: #ececee;
  margin: 4px 0;
}

.pop-scroll {
  max-height: 280px;
  overflow-y: auto;
}

.pop-search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 9px;
  margin-bottom: 4px;
  border-bottom: 1px solid #ececee;
  color: var(--muted);
}

.pop-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.pop-section-hdr {
  padding: 7px 8px 4px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pop-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px 8px 8px;
}

.tag-pop {
  width: 300px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: #f1f1f3;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.2;
}

.tag-pill:hover {
  background: #e7e7ea;
}

.tag-pill.on {
  border-color: rgba(30, 122, 254, 0.3);
  background: rgba(30, 122, 254, 0.12);
  color: var(--accent-strong);
}

.content {
  flex: 1;
  width: min(calc(100% - 48px), 1680px);
  margin: 0 auto;
  padding: 16px 0 80px;
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  width: 100%;
}

.tile {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  border-radius: 6px;
  background: #ececee;
  cursor: zoom-in;
  isolation: isolate;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.56) 0%, rgba(0, 0, 0, 0) 34%, rgba(0, 0, 0, 0) 66%, rgba(0, 0, 0, 0.58) 100%);
}

.tile:hover::after {
  opacity: 1;
}

.tile-img,
.tile-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-img {
  z-index: 1;
}

.tile-video {
  z-index: 2;
  opacity: 0;
  transition: opacity 0.14s ease;
  background: #000;
}

.tile:hover .tile-video {
  opacity: 1;
}

.tile-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: linear-gradient(135deg, #f0f0f2, #dedee2);
  font-size: 12px;
}

.ov {
  position: absolute;
  z-index: 4;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.14s ease;
  pointer-events: none;
}

.tile:hover .ov {
  opacity: 1;
  pointer-events: auto;
}

.ov-tl {
  top: 8px;
  left: 8px;
  right: 8px;
  flex-direction: column;
  align-items: flex-start;
}

.ov-br {
  right: 8px;
  bottom: 8px;
}

.ov-filename,
.ov-loc,
.dur-badge {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ov-filename {
  padding: 4px 8px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 500;
}

.ov-loc {
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 500;
}

.ov-dl {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.26);
}

.ov-dl:hover {
  background: #146cf0;
}

.dur-badge {
  position: absolute;
  z-index: 4;
  bottom: 8px;
  left: 8px;
  padding: 3px 6px;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.tile:hover .dur-badge {
  opacity: 0;
}

.sentinel {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.loading-pulse {
  animation: pulse 1.35s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

.end-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 0 0;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.end-marker .hr {
  width: 80px;
  max-width: 20vw;
  height: 1px;
  background: #d9d9dc;
}

.empty {
  min-height: 48vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-card {
  width: min(100%, 380px);
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted-2);
}

.empty-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 5px;
}

.empty-sub {
  margin-bottom: 16px;
  line-height: 1.45;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(20, 22, 26, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal {
  position: relative;
  width: 100%;
  max-width: 1320px;
  height: calc(100vh - 64px);
  max-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5);
}

.loading-modal {
  min-height: 360px;
  display: block;
}

.modal-close,
.modal-nav {
  position: absolute;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.modal-close {
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.modal-nav {
  top: 50%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  transform: translateY(-50%);
}

.modal-nav.prev {
  left: 12px;
}

.modal-nav.next {
  right: 392px;
}

.modal-media {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1013;
}

.modal-img,
.modal-video {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 64px);
  object-fit: contain;
}

.modal-video {
  width: 100%;
  background: #000;
}

.modal-empty {
  color: #fff;
  padding: 30px;
  text-align: center;
}

.modal-meta {
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  padding: 22px;
  border-left: 1px solid #ececee;
}

.mm-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mm-type-row,
.mm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mm-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  background: #f1f1f3;
  color: #4a4a52;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mm-fname {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

.mm-loc {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12.5px;
}

.mm-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mm-h {
  margin: 0;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mm-desc {
  margin: 0;
  color: #2c2d31;
  font-size: 13px;
  line-height: 1.5;
}

.mm-meta-grid {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
  font-size: 12.5px;
}

.mm-meta-grid dt {
  color: var(--muted-2);
}

.mm-meta-grid dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.raw-block {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid #e7e7ea;
  background: #f6f6f7;
  color: #303136;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.mm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 480px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 8px 0;
  font-size: 24px;
  letter-spacing: 0;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  display: inline-flex;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.field input {
  width: 100%;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
}

.status-line {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
}

.status-line.is-error {
  color: var(--danger);
}

@media (max-width: 980px) {
  .hdr {
    gap: 12px;
    padding: 0 12px;
  }

  .hdr-left,
  .hdr-right {
    min-width: 0;
  }

  .hdr-sub,
  .user-pill {
    display: none;
  }

  .filterbar {
    top: 54px;
    align-items: flex-start;
    padding: 7px 12px;
  }

  .fb-right {
    flex-shrink: 0;
  }

  .content {
    width: calc(100% - 24px);
  }

  .modal {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(220px, 42vh);
    max-height: calc(100vh - 32px);
    height: calc(100vh - 32px);
  }

  .modal-meta {
    max-height: none;
    border-left: 0;
    border-top: 1px solid #ececee;
  }

  .modal-nav.next {
    right: 12px;
  }
}

@media (max-width: 680px) {
  .hdr {
    height: auto;
    min-height: 54px;
    flex-wrap: wrap;
    padding: 8px 12px;
  }

  .hdr-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

  .filterbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .fb-left,
  .fb-right {
    flex-wrap: wrap;
  }

  .result-count {
    margin-right: auto;
  }

  .chip-row {
    padding: 8px 12px 0;
  }

  .content {
    width: calc(100% - 16px);
    padding-top: 8px;
  }

  .modal-backdrop {
    padding: 12px;
  }

  .mm-meta-grid {
    grid-template-columns: 1fr;
  }
}
