/* Civitai: browse and install (js/views/civitai.js). Tokens only. */

.cv-tools { gap: var(--sp-2); margin-bottom: var(--sp-3); }
.cv-tools .search { min-width: 220px; flex: 1 1 220px; }
.cv-tools select { max-width: 200px; }

.cv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--sp-3);
}

.cv-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  text-align: left;
  color: inherit;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
}
.cv-card:hover { border-color: var(--accent-line); }
.cv-card-body { padding: var(--sp-2) var(--sp-3) var(--sp-3); display: flex; flex-direction: column; gap: 2px; }
.cv-card-title { font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cv-badges { position: absolute; top: var(--sp-2); left: var(--sp-2); display: flex; gap: 4px; }

.cv-pic {
  position: relative;
  display: grid;
  place-items: center;
  background: var(--s3);
  color: var(--fg-3);
  overflow: hidden;
}
.cv-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-cover { aspect-ratio: 3 / 4; }
.cv-thumb { width: 44px; height: 56px; border-radius: var(--r-sm); flex: none; }
.cv-play { position: absolute; right: 6px; bottom: 6px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }

.cv-detail { display: flex; flex-direction: column; gap: var(--sp-4); }
.cv-detail > .btn { align-self: flex-start; }
.cv-head { display: flex; flex-direction: column; gap: var(--sp-2); }
.cv-versions { gap: var(--sp-2); }
.cv-strip { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-2); }
.cv-shot { flex: none; height: 280px; padding: 0; border: 0; border-radius: var(--r-md); overflow: hidden; cursor: zoom-in; background: var(--s3); }
.cv-shot .cv-pic { height: 100%; }
.cv-shot .cv-pic img { width: auto; height: 100%; }
.cv-version h3, .cv-review h3 { margin: var(--sp-2) 0; }
.cv-ok { display: flex; align-items: center; gap: var(--sp-2); color: var(--ok); }
.cv-about { white-space: pre-line; max-width: 72ch; }
.cv-local { grid-template-columns: auto minmax(0, 1fr) auto auto auto; align-items: center; }
.cv-progress { width: 100%; max-width: 520px; }

.cv-viewer .cv-viewer-card {
  width: min(1400px, 96vw);
  height: min(900px, 92vh);
  display: flex;
  flex-direction: column;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.cv-viewer-bar { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); }
.cv-viewer-body { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.cv-stage { display: grid; place-items: center; background: #000; min-height: 0; }
.cv-stage img, .cv-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.cv-side { overflow-y: auto; padding: var(--sp-3) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); border-left: 1px solid var(--border); }
.cv-side h3 { margin: 0 0 var(--sp-1); font-size: 14px; }
.cv-prompt { white-space: pre-wrap; word-break: break-word; user-select: text; font-size: 13px; color: var(--fg-2); }

@media (max-width: 760px) {
  .cv-viewer-body { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
  .cv-side { border-left: 0; border-top: 1px solid var(--border); }
  .cv-shot { height: 200px; }
}

/* Readable over any cover picture. */
.cv-badges .pill { background: rgba(8, 9, 13, .78); backdrop-filter: blur(4px); }

/* Their workflow: a wider dialog with a scrolling list. */
.cv-theirs-card { width: min(720px, 94vw); max-height: 88vh; display: flex; flex-direction: column; gap: var(--sp-3); }
.cv-theirs { overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-3); }

/* Made by others: smaller tiles, a mark on the ones that carry a workflow. */
.cv-community .cv-shot { position: relative; height: 200px; }
.cv-wf { position: absolute; top: 6px; left: 6px; background: rgba(8, 9, 13, .78); }

/* ------------------------------------------------ the model page, Civitai-like */

.cv-detail { max-width: 1480px; }
.cv-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.cv-title { margin: 0; font-size: clamp(22px, 2.6vw, 34px); line-height: 1.15; font-weight: 750; letter-spacing: -.01em; }
.cv-counts { display: flex; gap: var(--sp-2); flex: none; }
.cv-count {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: var(--s3); border: 1px solid var(--border); border-radius: var(--r-sm); font-weight: 650;
}
.cv-count .icon { width: 16px; height: 16px; }
.cv-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.cv-chip {
  padding: 3px 8px; border-radius: 6px; background: var(--s3); color: var(--fg-2);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.cv-chip.accent { background: var(--accent-soft); color: var(--accent-2); }
.cv-chip.bad { background: var(--danger-soft); color: var(--danger); }

.cv-versions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    margin-bottom: 6px;
}
.cv-version-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--s2);
  color: var(--fg-2); font-weight: 650; cursor: pointer;
}
.cv-version-tab:hover { border-color: var(--border-2); color: var(--fg); }
.cv-version-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.cv-version-tab .icon { width: 14px; height: 14px; }
.cv-ea { display: inline-flex; }
.cv-ea.warn { color: var(--warn); }
.cv-ea.ok { color: var(--ok); }
.cv-version-tab.on .cv-ea { color: #fff; }

.cv-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--sp-5); align-items: start; }
.cv-main, .cv-aside { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }

.cv-card-box {
  background: var(--s1); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3);
}
.cv-card-box h3 { margin: 0; font-size: 15px; }

/* The showcase: the version's pictures, big, side by side. */
.cv-showcase { position: relative; }
.cv-show-track {
  display: flex; gap: var(--sp-3); overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; border-radius: var(--r-lg);
}
.cv-show-track::-webkit-scrollbar { display: none; }
.cv-show-item {
  position: relative; flex: none; height: clamp(320px, 62vh, 680px); padding: 0; border: 0;
  border-radius: var(--r-lg); overflow: hidden; background: var(--s3); cursor: zoom-in; scroll-snap-align: start;
}
.cv-show-item img { height: 100%; width: auto; max-width: none; display: block; }
.cv-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: rgba(238, 241, 247, .85); color: #111; font-size: 26px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-2); display: grid; place-items: center;
}
.cv-arrow:hover { background: #fff; }
.cv-arrow.left { left: 12px; }
.cv-arrow.right { right: 12px; }

/* The maker's write-up. */
.cv-desc { max-height: 460px; overflow: hidden; position: relative; color: var(--fg-2); line-height: 1.6; overflow-wrap: anywhere; }
.cv-desc:not(.open)::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 80px;
  background: linear-gradient(transparent, var(--s1)); pointer-events: none;
}
.cv-desc.open { max-height: none; }
.cv-desc.open::after { display: none; }
.cv-desc p { margin: 0 0 .8em; }
.cv-desc h3, .cv-desc h4 { color: var(--fg); margin: 1em 0 .4em; }
.cv-desc strong, .cv-desc b { color: var(--fg); }
.cv-desc a { color: var(--accent-2); }
.cv-desc pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: var(--sp-3); white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; color: var(--fg);
}
.cv-desc code { font-family: var(--mono); font-size: .92em; }
.cv-desc ul, .cv-desc ol { padding-left: 1.4em; margin: 0 0 .8em; }
.cv-more { align-self: flex-start; }

/* Getting it. */
.cv-get-main { display: flex; flex-direction: column; gap: var(--sp-2); }
.cv-install { width: 100%; justify-content: center; padding-block: 12px; font-size: 15px; }
.cv-file { overflow-wrap: anywhere; }

/* Details, like Civitai's table. */
.cv-row {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
  padding: 9px 0; border-top: 1px solid var(--border); font-size: 13.5px;
}
.cv-card-box h3 + .cv-row { border-top: 0; }
.cv-row-label { color: var(--fg-2); }
.cv-row-value { text-align: right; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.cv-row-value .icon { width: 14px; height: 14px; }
.cv-row-value > span { display: inline-flex; align-items: center; gap: 4px; }
.cv-hash {
  display: inline-flex; border: 1px solid var(--border-2); border-radius: 6px; overflow: hidden;
  background: transparent; color: var(--fg); font-family: var(--mono); font-size: 12px; cursor: copy; padding: 0;
}
.cv-hash span { padding: 3px 8px; }
.cv-hash-kind { background: var(--s3); border-right: 1px solid var(--border-2); font-weight: 700; }
.cv-open { align-self: flex-start; }

/* Trigger words: each one copies. */
.cv-triggers { display: flex; flex-direction: column; gap: 6px; }
.cv-trigger {
  display: flex; align-items: flex-start; gap: 8px; text-align: left; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); border: 1px solid var(--accent-line);
  background: var(--accent-soft); color: var(--fg); font-size: 12.5px; line-height: 1.45; cursor: copy;
}
.cv-trigger span { flex: 1; overflow-wrap: anywhere; }
.cv-trigger .icon { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--accent-2); }
.cv-trigger:hover { border-color: var(--accent); }

.cv-creator { flex-direction: row; align-items: center; }
.cv-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex: none; background: var(--s3); }
.cv-avatar.blank { display: grid; place-items: center; font-weight: 700; color: var(--fg-2); }
.cv-creator-name { font-weight: 700; }

/* Below: yours, then everyone's. */
.cv-section { display: flex; flex-direction: column; gap: var(--sp-3); }
.cv-section:empty { display: none; }
.cv-section-head { gap: var(--sp-3); }
.cv-section-title { margin: var(--sp-2) 0 0; font-size: 24px; font-weight: 750; display: flex; align-items: center; gap: var(--sp-2); }
.cv-section-count { font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: var(--r-pill); background: var(--s3); color: var(--fg-2); }
.cv-sort { max-width: 200px; }

.cv-mine { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-2); }
.cv-mine-item {
  position: relative; aspect-ratio: 3 / 4; padding: 0; border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden; background: var(--s3); cursor: zoom-in;
}
.cv-mine-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-mine-when {
  position: absolute; left: 6px; bottom: 6px; padding: 2px 6px; border-radius: 6px;
  background: rgba(8, 9, 13, .78); color: var(--fg-2); font-size: 11px;
}

.cv-wall { columns: 4 260px; column-gap: var(--sp-3); }
.cv-post {
  display: inline-flex; flex-direction: column; width: 100%; margin: 0 0 var(--sp-3); break-inside: avoid;
  padding: 0; text-align: left; color: inherit; background: var(--s1);
  border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; cursor: zoom-in;
}
.cv-post:hover { border-color: var(--border-2); }
.cv-post-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); padding: 10px 12px; }
.cv-post-user { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-post-pic { position: relative; background: var(--s3); min-height: 120px; }
.cv-post-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-post-react { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 12px; font-size: 12.5px; color: var(--fg-2); }
.cv-post-react:empty { display: none; }
.cv-wall-foot { display: flex; justify-content: center; padding: var(--sp-2) 0 var(--sp-5); }

@media (max-width: 1100px) {
  /* One column: the pictures, then getting it, then the write-up. */
  .cv-layout { display: flex; flex-direction: column; }
  .cv-main { display: contents; }
  .cv-showcase { order: 1; }
  .cv-aside { order: 2; width: 100%; }
  .cv-main > .cv-card-box { order: 3; }
  .cv-show-item { height: clamp(260px, 52vh, 520px); }
}
@media (max-width: 600px) {
  .cv-wall { columns: 2 150px; column-gap: var(--sp-2); }
  .cv-post { margin-bottom: var(--sp-2); }
  .cv-post-head { padding: 8px; }
  .cv-arrow { width: 36px; height: 36px; font-size: 22px; }
  .cv-counts { width: 100%; }
}
