/* Theme tokens — mirrors versos-processor cs.html */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --panel: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --border: #e5e7eb;
  --border-soft: #ececec;
  --accent: #EB8B4C;
  --accent-hover: #D97A3D;
  --accent-soft: rgba(235, 139, 76, 0.10);
  --accent-grad: linear-gradient(135deg, #F5A56F 0%, #EB8B4C 100%);
  --accent-line: linear-gradient(90deg, #ECC334 0%, #EB8B4C 50%, #ECC334 100%);
  --shadow-md: 0 4px 6px -1px rgba(17,24,39,.05), 0 2px 4px -2px rgba(17,24,39,.04);
  --shadow-lg: 0 10px 15px -3px rgba(17,24,39,.06), 0 4px 6px -4px rgba(17,24,39,.04);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --canvas-bg: #e9edf2;
}
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --panel: #232839;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --muted2: #64748b;
  --border: #2d3348;
  --border-soft: #232839;
  --accent: #F5A56F;
  --accent-hover: #FFC093;
  --accent-soft: rgba(245, 165, 111, 0.14);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.4), 0 4px 6px -4px rgba(0,0,0,.3);
  --canvas-bg: #0f1117;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font: 15px/1.5 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- brand block (CS logo + powered-by Versos) ---------- */
.brand-block { display: inline-flex; flex-direction: column; gap: 5px; color: var(--text); width: 148px; }
.brand-block .cs-logo { width: 100%; height: auto; display: block; color: var(--text); }
.powered-by {
  display: flex; align-items: center; gap: 6px;
  font-size: 8.5px; font-weight: 700; letter-spacing: .12em;
  color: var(--muted); text-transform: uppercase; white-space: nowrap;
}
.powered-by .versos-logo { height: 11px; width: auto; margin-top: -1px; filter: invert(1) brightness(0.15); }
[data-theme="dark"] .powered-by .versos-logo { filter: none; }
.brand-block.compact { width: 118px; }

.theme-toggle {
  width: 38px; height: 38px; border-radius: var(--radius-sm); flex: none;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; display: inline-grid; place-items: center; transition: border-color var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-moon { display: block; }

/* ---------- landing ---------- */
.site-header { position: relative; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.site-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--accent-line); opacity: .9;
}
.header-inner {
  padding: 16px 32px; display: flex; align-items: center;
  justify-content: space-between; gap: 24px;
}
.header-title { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.landing-main { max-width: 880px; margin: 0 auto; padding: 48px 24px; }
.landing-main h1 { font-size: 26px; font-weight: 800; margin-bottom: 8px; }
.lede { color: var(--muted); max-width: 62ch; margin-bottom: 32px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-md);
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-thumb {
  position: relative; overflow: hidden;
  height: 190px; display: grid; place-items: center;
  background: var(--panel);
  color: var(--muted2); font-size: 34px; font-weight: 700; letter-spacing: 2px;
}
.card-thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 70%;
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.card-body h2 { font-size: 18px; font-weight: 700; }
.card-body a { color: inherit; }
.open-btn { margin-top: 10px; color: var(--accent); font-weight: 600; }
.site-footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px 0 32px; }

/* ---------- download buttons ---------- */
.dl-row { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.dl-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 600; line-height: 1.3;
  transition: border-color var(--transition), background var(--transition);
}
.dl-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dl-btn svg { width: 17px; height: 17px; flex: none; color: var(--accent); }
.dl-btn em { display: block; font-style: normal; font-weight: 400; font-size: 11.5px; color: var(--muted); }

/* ---------- viewer ---------- */
.viewer-page { overflow: hidden; }
#app { display: flex; height: 100vh; }
#sidebar {
  width: 320px; min-width: 320px; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar-head { position: relative; padding: 16px 18px 12px; border-bottom: 1px solid var(--border-soft); }
.sidebar-head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: var(--accent-line); opacity: .9; z-index: 1;
}
.sidebar-top-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sidebar-head .back { font-size: 13px; font-weight: 600; }
.sidebar-head h1 { font-size: 17px; font-weight: 700; margin-top: 10px; }
.panel { flex: 1; overflow-y: auto; padding: 12px 18px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-title-row h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mini-btns { display: flex; gap: 6px; }
.mini-btns button {
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  transition: border-color var(--transition);
}
.mini-btns button:hover { border-color: var(--accent); }
.slider-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; color: var(--muted); margin-bottom: 10px;
}
.slider-row input { flex: 1; accent-color: var(--accent); }

.instance-list details { margin-bottom: 4px; }
.instance-list summary {
  cursor: pointer; font-size: 13.5px; font-weight: 600; padding: 5px 4px;
  list-style: none; display: flex; align-items: center; gap: 8px; user-select: none;
}
.instance-list summary::before { content: "▸"; color: var(--muted); font-size: 11px; transition: transform .12s; }
.instance-list details[open] summary::before { transform: rotate(90deg); }
.inst-count { color: var(--muted); font-weight: 400; font-size: 12px; }
.inst-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px 4px 20px; border-radius: 6px; font-size: 13.5px;
}
.inst-row:hover { background: var(--accent-soft); }
.inst-row input { accent-color: var(--accent); }
.chip { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.inst-name { flex: 1; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-name:hover { color: var(--accent); }
.tier { font-size: 10px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); }
.tier.hi { color: #16a34a; border-color: #86efac; }
[data-theme="dark"] .tier.hi { color: #7affc6; border-color: #2c5c4a; }

.sidebar-foot { padding: 12px 18px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.check-row { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check-row input { accent-color: var(--accent); }

#canvas-wrap { flex: 1; position: relative; background: var(--canvas-bg); }
#c { width: 100%; height: 100%; display: block; }

#loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(2px); z-index: 5;
}
.load-box { width: min(380px, 80%); text-align: center; }
.load-box p { margin-bottom: 10px; }
.bar { height: 8px; border-radius: 6px; background: var(--panel); overflow: hidden; border: 1px solid var(--border); }
#load-fill { height: 100%; width: 0%; background: var(--accent-grad); transition: width .2s; }
#load-detail { margin-top: 8px; }

#hover-tip {
  position: absolute; pointer-events: none; display: none; z-index: 4;
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 6px; font-size: 12.5px;
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-top: 12px; }
.tab {
  flex: 1; padding: 6px 0; font-size: 13.5px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  background: var(--panel); color: var(--muted); border: 1px solid var(--border);
  font-family: inherit; transition: border-color var(--transition), color var(--transition);
}
.tab.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- 2D image gallery ---------- */
#images-view { flex: 1; overflow-y: auto; background: var(--bg); }
.gallery-inner { max-width: 1200px; margin: 0 auto; padding: 26px 28px 60px; }
.gallery-inner h2 { font-size: 17px; font-weight: 700; margin: 22px 0 12px; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.g-cell {
  cursor: zoom-in; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; transition: border-color var(--transition); box-shadow: var(--shadow-md);
}
.g-cell:hover { border-color: var(--accent); }
.g-cell img { width: 100%; aspect-ratio: 9/16; object-fit: cover; display: block; background: var(--panel); }
.g-cell figcaption { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }

.gallery-bar {
  display: flex; align-items: center; gap: 14px; margin-bottom: 4px;
  position: sticky; top: 0; background: var(--bg); padding: 14px 0 10px; z-index: 3;
}
.gallery-bar input {
  flex: 0 1 340px; padding: 8px 12px; font-size: 14px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); font-family: inherit;
}
.gallery-bar input:focus { outline: none; border-color: var(--accent); }
.badge-masks {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; align-self: flex-start;
  color: #16a34a; border: 1px solid #86efac;
}
[data-theme="dark"] .badge-masks { color: #7affc6; border-color: #2c5c4a; }

/* ---------- lightbox ---------- */
#lightbox {
  position: fixed; inset: 0; z-index: 20; background: rgba(10, 13, 16, .8);
  display: flex; align-items: center; justify-content: center;
}
#lightbox[hidden] { display: none; }
.lb-main {
  display: flex; gap: 0; width: min(1240px, 94vw); height: min(760px, 90vh);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.lb-img-wrap { flex: 1.4; background: #000; position: relative; min-width: 0; }
.lb-img-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.lb-meta { flex: 1; min-width: 300px; max-width: 420px; padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.lb-meta h3 { font-size: 17px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; max-height: 110px; overflow-y: auto; }
.chip-tag {
  font-size: 12px; padding: 2px 9px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.chip-tag b { color: var(--text); }
.lb-table-wrap { flex: 1; overflow-y: auto; border-top: 1px solid var(--border); margin-top: 4px; }
.lb-table-wrap table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lb-table-wrap th, .lb-table-wrap td { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--border-soft); }
.lb-table-wrap th { color: var(--muted); position: sticky; top: 0; background: var(--surface); font-weight: 600; }
.mono { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--muted); }
#lb-close {
  position: absolute; top: 18px; right: 24px; font-size: 30px; line-height: 1;
  background: none; border: none; color: #cbd5e1; cursor: pointer;
}
#lb-close:hover { color: #fff; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 44px; background: none; border: none; color: #cbd5e1; cursor: pointer; padding: 10px;
}
.lb-nav:hover { color: #fff; }
#lb-prev { left: 8px; }
#lb-next { right: 8px; }

@media (max-width: 760px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; max-height: 45vh; order: 2; }
}
