/* Bhakti Marga Visual Intelligence Platform — design tokens from
   my.bmvaikhunta.org/design-system */
:root {
  --brand-deep: #041236;
  --brand-night: #0a122b;
  --brand-primary: #16254c;
  --brand-secondary: #5a6b85;
  --brand-gold: #b5924b;
  --brand-gold-light: #d6bf90;
  --devotional-blue: #00a0af;
  --devotional-green: #7a9754;
  --devotional-orange: #f15928;
  --devotional-purple: #55329a;
  --devotional-red: #9a1e36;
  --devotional-yellow: #fcb001;
  --canvas: #f1f4ff;
  --canvas-muted: #e8ecf9;
  --focus: #007f8c;
  --action: #16254c;
  --action-hover: #0d1836;
  --r-control: 10px;
  --r-card: 16px;
  --r-panel: 22px;
  --control-h: 38px;
  --text: #16254c;
  --text-soft: #5a6b85;
  --surface: #ffffff;
  --line: #d6dbf0;
  --shadow: 0 10px 30px rgba(4, 18, 54, .10);
  --font: "Avenir Next", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--canvas);
  color: var(--text);
  min-height: 100vh;
}
img { display: block; }
button, input, select { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; height: var(--control-h); padding: 0 18px;
  border-radius: var(--r-control); border: 1px solid transparent;
  background: var(--action); color: #fff; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--action-hover); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn-gold { background: var(--brand-gold); color: #fff; }
.btn-gold:hover { background: #9c7c3c; }
.btn-outline {
  background: transparent; color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline:hover { background: var(--canvas-muted); }
.btn-ghost { background: transparent; color: inherit; border-color: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
main .btn-ghost:hover, .modal-card .btn-ghost:hover { background: var(--canvas-muted); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-danger { color: var(--devotional-red); }

input[type="search"], input[type="text"], input[type="password"],
input[type="date"], input[type="number"], select {
  height: var(--control-h); border: 1px solid var(--line);
  border-radius: var(--r-control); padding: 0 12px; background: #fff;
  color: var(--text);
}
input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}

/* -------------------------------------------------------------- topbar */
.topbar {
  background: linear-gradient(135deg, var(--brand-deep), var(--brand-primary));
  color: #fff; position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 14px rgba(4,18,54,.35);
}
.topbar-inner {
  max-width: 1480px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand img { width: 38px; height: 38px; }
.brand-name { font-size: 19px; letter-spacing: .4px; line-height: 1.1; }
.brand-name strong { color: var(--brand-gold-light); }
.brand-sub { display: block; font-size: 10.5px; color: #b7c3e3; letter-spacing: .8px; text-transform: uppercase; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  color: #cdd7f0; text-decoration: none; padding: 8px 14px;
  border-radius: var(--r-control); font-weight: 600; font-size: 14px;
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.16); color: var(--brand-gold-light); }
.topbar-right { display: flex; align-items: center; gap: 10px; color: #cdd7f0; }
.ai-badge {
  background: var(--devotional-blue); color: #fff; font-size: 11px;
  font-weight: 700; letter-spacing: .5px; padding: 4px 10px;
  border-radius: 999px; text-transform: uppercase;
}

/* ---------------------------------------------------------------- views */
main { max-width: 1480px; margin: 0 auto; padding: 24px 20px 80px; }
.view-head h2, .hero h2 { margin: 6px 0 4px; font-size: 26px; }
.view-sub { color: var(--text-soft); margin: 0 0 18px; }
.section-title { margin: 30px 0 10px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.hint { color: var(--text-soft); font-size: 13px; margin: 0 0 12px; }
.empty { color: var(--text-soft); text-align: center; padding: 40px 0; }

.panel {
  background: var(--surface); border-radius: var(--r-panel);
  padding: 20px 24px; margin-top: 20px; box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- hero */
.hero {
  background: var(--surface); border-radius: var(--r-panel);
  padding: 26px 28px 20px; box-shadow: var(--shadow); margin-bottom: 22px;
}
.searchbar {
  display: flex; gap: 10px; align-items: center; margin: 14px 0 12px;
  position: relative;
}
.search-icon {
  width: 20px; height: 20px; position: absolute; left: 14px;
  color: var(--brand-secondary); pointer-events: none;
}
#search-input {
  flex: 1; height: 48px; font-size: 16px; padding-left: 44px;
  border-radius: 14px; border: 1.5px solid var(--line);
}
#search-input:focus-visible { border-color: var(--focus); }
.by-image-btn { border: 1px dashed var(--line); color: var(--text-soft); height: 48px; }
#search-btn { height: 48px; padding: 0 26px; font-size: 15px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-context {
  margin-top: 12px; padding: 8px 14px; background: var(--canvas-muted);
  border-radius: var(--r-control); font-size: 13.5px; color: var(--brand-primary);
  display: flex; align-items: center; gap: 10px;
}

/* ---------------------------------------------------------------- grid */
.grid { column-count: 5; column-gap: 14px; }
@media (max-width: 1500px) { .grid { column-count: 4; } }
@media (max-width: 1100px) { .grid { column-count: 3; } }
@media (max-width: 760px)  { .grid { column-count: 2; } }
@media (max-width: 480px)  { .grid { column-count: 1; } }
.grid-small { column-count: 6; }
@media (max-width: 1100px) { .grid-small { column-count: 4; } }

.ph-card {
  break-inside: avoid; margin: 0 0 14px; position: relative;
  border-radius: var(--r-card); overflow: hidden; cursor: pointer;
  background: var(--canvas-muted); box-shadow: 0 3px 12px rgba(4,18,54,.08);
  /* translateZ isolates each card's paint layer: without it, hover effects
     inside CSS columns make neighbouring cards flicker in Chrome */
  transform: translateZ(0);
  transition: box-shadow .15s ease;
}
.ph-card:hover { box-shadow: 0 10px 24px rgba(4,18,54,.26); }
.ph-card img { width: 100%; height: auto; transition: transform .2s ease; }
.ph-card:hover img { transform: scale(1.03); }
.ph-overlay {
  position: absolute; inset: auto 0 0 0;
  background: linear-gradient(transparent, rgba(4,18,54,.82));
  color: #fff; padding: 26px 12px 10px; font-size: 12.5px;
  opacity: 0; transition: opacity .15s ease;
}
.ph-card:hover .ph-overlay { opacity: 1; }
.ph-overlay .t { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-overlay .a { color: #cdd7f0; }
.ph-badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }

.chip {
  display: inline-flex; align-items: center; font-size: 11.5px;
  font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--canvas-muted); color: var(--brand-primary);
}
.chip-gold { background: var(--brand-gold); color: #fff; }
.chip-red { background: var(--devotional-red); color: #fff; }
.chip-blue { background: var(--devotional-blue); color: #fff; }
.chip-score { background: rgba(4,18,54,.72); color: #fff; }

.load-more-wrap { text-align: center; margin: 24px 0; }

/* --------------------------------------------------------------- review */
.review-album { min-width: 320px; }
.strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.strip .ph-card { width: 190px; flex: 0 0 auto; margin: 0; }
.dup-group {
  background: var(--surface); border-radius: var(--r-card);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.dup-group .strip .ph-card.best { outline: 3px solid var(--brand-gold); }
.dup-group-head { font-size: 13px; color: var(--text-soft); margin-bottom: 10px; }

/* ------------------------------------------------------------- timeline */
.year-block { margin-bottom: 34px; }
.year-title {
  font-size: 30px; color: var(--brand-primary); margin: 0 0 4px;
  display: flex; align-items: baseline; gap: 14px;
}
.year-title .n { color: var(--text-soft); font-size: 14px; font-weight: 400; }
.album-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-top: 12px; }
.album-card {
  background: var(--surface); border-radius: var(--r-card); overflow: hidden;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .15s ease;
}
.album-card:hover { transform: translateY(-2px); }
.album-card .cover { width: 100%; aspect-ratio: 3/2; object-fit: cover; background: var(--canvas-muted); }
.album-card .body { padding: 10px 14px 14px; }
.album-card .body .t { font-weight: 600; font-size: 14px; }
.album-card .body .d { color: var(--text-soft); font-size: 12.5px; margin-top: 2px; }
.year-events { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.event-pill {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--canvas-muted); color: var(--brand-primary);
  border-left: 4px solid var(--devotional-blue);
}

/* ---------------------------------------------------------- collections */
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.collection-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.collection-card {
  background: var(--surface); border-radius: var(--r-card); overflow: hidden;
  cursor: pointer; box-shadow: var(--shadow);
}
.collection-card .cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--brand-primary); }
.collection-card .body { padding: 12px 14px; }
.collection-head { display: flex; align-items: center; gap: 12px; margin: 10px 0 18px; flex-wrap: wrap; }
.collection-head h3 { margin: 0; flex: 1; }

/* ------------------------------------------------------------ dashboard */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface); border-radius: var(--r-card);
  padding: 16px 18px; box-shadow: var(--shadow);
  border-top: 4px solid var(--brand-gold);
}
.stat-card .v { font-size: 26px; font-weight: 700; color: var(--brand-primary); }
.stat-card .l { font-size: 12.5px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .5px; }
.pipeline-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.pipeline-params { display: flex; gap: 18px; color: var(--text-soft); font-size: 13px; align-items: center; }
.pipeline-params input { width: 80px; height: 32px; margin-left: 6px; }
.job-row {
  display: flex; gap: 14px; align-items: baseline; padding: 10px 0;
  border-bottom: 1px solid var(--canvas-muted); font-size: 13.5px;
  flex-wrap: wrap;
}
.job-row .k { font-weight: 700; min-width: 110px; }
.job-row .log {
  flex-basis: 100%; white-space: pre-wrap; font-family: ui-monospace, monospace;
  font-size: 12px; color: var(--text-soft); background: var(--canvas);
  border-radius: 8px; padding: 8px 10px; max-height: 160px; overflow: auto;
}
.st { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; }
.st-queued { background: var(--canvas-muted); color: var(--brand-secondary); }
.st-running { background: var(--devotional-yellow); color: var(--brand-deep); }
.st-done { background: var(--devotional-green); color: #fff; }
.st-error { background: var(--devotional-red); color: #fff; }

/* ------------------------------------------------------------- lightbox */
.lightbox { position: fixed; inset: 0; z-index: 60; }
.lightbox-backdrop, .modal-backdrop { position: absolute; inset: 0; background: rgba(4,18,54,.82); }
.lightbox-panel {
  position: absolute; inset: 3vh 3vw; background: var(--surface);
  border-radius: var(--r-panel); display: flex; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.lightbox-close {
  position: absolute; top: 10px; right: 14px; z-index: 2;
  background: rgba(4,18,54,.6); color: #fff; border: 0; font-size: 26px;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
.lightbox-media {
  flex: 1; background: var(--brand-night); display: flex;
  align-items: center; justify-content: center; min-width: 0;
}
.lightbox-media img { max-width: 100%; max-height: 94vh; object-fit: contain; }
.lightbox-side { width: 360px; flex: 0 0 360px; padding: 22px; overflow-y: auto; }
.lightbox-side h3 { margin: 0 0 2px; font-size: 18px; }
.lb-album { color: var(--brand-gold); font-weight: 600; font-size: 13px; margin: 0 0 10px; }
.lb-caption { font-size: 14px; color: var(--text); font-style: italic; }
.lb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.lb-meta { font-size: 13px; display: grid; grid-template-columns: 110px 1fr; gap: 3px 10px; margin: 14px 0; }
.lb-meta dt { color: var(--text-soft); }
.lb-meta dd { margin: 0; }
.lb-quality { margin: 10px 0 16px; }
.qbar { margin-bottom: 8px; font-size: 12px; color: var(--text-soft); }
.qbar .bar { height: 6px; background: var(--canvas-muted); border-radius: 3px; margin-top: 3px; }
.qbar .fill { height: 100%; border-radius: 3px; background: var(--devotional-green); }
.qbar .fill.low { background: var(--devotional-red); }
.qbar .fill.mid { background: var(--devotional-yellow); }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.lb-downloads { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--canvas-muted); }
.lb-dl-label { font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .5px; }
.lb-similar-title { margin: 16px 0 8px; font-size: 14px; }
.lb-similar-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lb-similar-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }

/* ---------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 70; }
.modal-card {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--surface); border-radius: var(--r-panel); padding: 24px;
  width: min(420px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal-card h3 { margin: 0 0 14px; }
.collect-option {
  display: block; width: 100%; text-align: left; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r-control);
  background: #fff; cursor: pointer; margin-bottom: 8px; font-weight: 600;
  color: var(--text);
}
.collect-option:hover { background: var(--canvas-muted); }
.modal-close { margin-top: 10px; }

/* ---------------------------------------------------------------- login */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(0,160,175,.25), transparent),
    radial-gradient(900px 500px at -10% 110%, rgba(181,146,75,.25), transparent),
    linear-gradient(150deg, var(--brand-deep), var(--brand-night));
  display: flex; align-items: center; justify-content: center;
}
.login-card { text-align: center; color: #fff; width: min(380px, 90vw); }
.login-logo { width: 84px; margin: 0 auto 18px; }
.login-card h1 { font-size: 24px; margin: 0 0 4px; }
.login-sub { color: #b7c3e3; margin: 0 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { height: 46px; text-align: center; font-size: 16px; border: 0; }
.login-card .btn { height: 46px; font-size: 15px; }
.login-error { color: #ffb4c0; font-size: 13.5px; margin: 0; }

/* ------------------------------------------------------------- designer */
#brief-input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 14px; font-size: 15px; font-family: inherit;
  color: var(--text); resize: vertical; margin-top: 8px;
}
#brief-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.brief-actions { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.brief-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }

/* --------------------------------------------------------------- studio */
.studio { position: fixed; inset: 0; z-index: 80; }
.studio-backdrop { position: absolute; inset: 0; background: rgba(4,18,54,.88); }
.studio-panel {
  position: absolute; inset: 2vh 2vw; background: var(--surface);
  border-radius: var(--r-panel); display: flex; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.studio-stage {
  flex: 1; min-width: 0; background: var(--brand-night);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 18px; gap: 10px;
}
.st-wrap { position: relative; max-width: 100%; max-height: calc(96vh - 90px); }
.st-wrap img {
  max-width: 100%; max-height: calc(96vh - 90px);
  object-fit: contain; user-select: none; -webkit-user-drag: none;
}
.st-note { color: #8fa0c8; font-size: 12px; margin: 0; text-align: center; }
.st-crop {
  position: absolute; border: 2px solid var(--brand-gold);
  box-shadow: 0 0 0 9999px rgba(4,18,54,.55); cursor: move;
  touch-action: none;
}
.st-crop-handle {
  position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px;
  background: var(--brand-gold); border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; touch-action: none;
}
.studio-side {
  width: 360px; flex: 0 0 360px; padding: 20px 22px; overflow-y: auto;
}
.studio-side h3 { margin: 0 0 14px; font-size: 18px; padding-right: 40px; }
.st-group { margin-bottom: 16px; }
.st-label { font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.st-aspects { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip-btn {
  border: 1px solid var(--line); background: #fff; color: var(--brand-primary);
  font-size: 12.5px; font-weight: 600; padding: 5px 11px;
  border-radius: 999px; cursor: pointer;
}
.chip-btn:hover { background: var(--canvas-muted); }
.chip-btn.active { background: var(--brand-gold); border-color: var(--brand-gold); color: #fff; }
.st-slider { display: block; margin-bottom: 10px; }
.st-slider-head {
  display: flex; justify-content: space-between; font-size: 13px;
  color: var(--text); margin-bottom: 2px;
}
.st-slider-head output { color: var(--brand-gold); font-weight: 700; }
.st-slider input[type="range"] { width: 100%; accent-color: var(--brand-gold); }
.st-actions { display: flex; gap: 8px; }
.st-variants { display: flex; flex-direction: column; gap: 10px; }
.st-variant {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  border: 1px solid var(--line); border-radius: var(--r-card);
}
.st-variant img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; }
.st-variant .meta { flex: 1; min-width: 0; }
.st-variant .meta .t { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-variant .meta .d { color: var(--text-soft); font-size: 12px; }

/* ---------------------------------------------------------- share links */
.share-panel {
  background: var(--surface); border-radius: var(--r-card);
  padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.share-dl-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text-soft); }
.share-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--canvas-muted); font-size: 13.5px; flex-wrap: wrap;
}
.share-row:last-child { border-bottom: 0; }
.share-row .url {
  font-family: ui-monospace, monospace; font-size: 12.5px;
  background: var(--canvas); padding: 6px 10px; border-radius: 8px;
  flex: 1; min-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.share-row .d { color: var(--text-soft); font-size: 12px; }
.share-usage {
  background: var(--canvas-muted); border-radius: var(--r-card);
  padding: 12px 16px; font-size: 13px; color: var(--brand-primary); margin: 0 0 18px;
}

@media (max-width: 900px) {
  .studio-panel { flex-direction: column; inset: 1vh 1vw; }
  .studio-side { width: auto; flex: 1; }
  .st-wrap img { max-height: 44vh; }
  .st-wrap { max-height: 44vh; }
}

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--brand-deep); color: #fff; padding: 12px 22px;
  border-radius: 999px; font-size: 14px; z-index: 120;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}

@media (max-width: 900px) {
  .lightbox-panel { flex-direction: column; inset: 2vh 2vw; }
  .lightbox-side { width: auto; flex: 1; }
  .lightbox-media img { max-height: 48vh; }
  .nav { overflow-x: auto; }
  .brand-sub { display: none; }
}
