/* BAW Randomset v2 — Design System
   Shared across all v2 views. Do not add page-specific rules here.
   ================================================================== */

:root {
  /* Backgrounds */
  --bg-0: #0a0c11;
  --bg-1: #0f121a;
  --bg-2: #151926;
  --bg-3: #1c2030;
  --bg-input: #0c0f17;

  /* Borders */
  --border-soft: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-focus: rgba(139, 124, 255, 0.55);

  /* Text */
  --fg-0: #f3f4f8;
  --fg-1: #c8ccd9;
  --fg-2: #8a90a3;
  --fg-3: #5a6075;
  --fg-disabled: #3a3f4f;

  /* Brand */
  --violet: #8b7cff;
  --violet-soft: rgba(139, 124, 255, 0.14);
  --violet-strong: #a597ff;
  --violet-deep: #6b5ce0;
  --mint: #3ddc97;
  --mint-soft: rgba(61, 220, 151, 0.13);
  --mint-deep: #2bb47a;
  --amber: #ffb547;
  --rose: #ff6b8a;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-md: 0 6px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 18px 60px rgba(0,0,0,0.55);
  --glow-violet: 0 0 0 1px rgba(139,124,255,0.3), 0 8px 32px rgba(139,124,255,0.18);
  --glow-mint: 0 0 0 1px rgba(61,220,151,0.3), 0 8px 32px rgba(61,220,151,0.15);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); background-clip: padding-box; border: 2px solid transparent; }

/* ===== Buttons ===== */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  background: var(--bg-3); color: var(--fg-0);
  border: 1px solid var(--border);
  transition: all 0.12s ease; white-space: nowrap;
}
.btn:hover { background: #232838; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--violet); color: #0a0c11; border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--violet-strong); }

.btn-mint { background: transparent; color: var(--mint); border: 1px solid var(--mint-soft); }
.btn-mint:hover { background: var(--mint-soft); border-color: var(--mint); }

.btn-mint-solid { background: var(--mint); color: #0a1d14; font-weight: 600; border-color: transparent; }
.btn-mint-solid:hover { background: #4ee5a3; }

.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--fg-1); }
.btn-ghost:hover { background: var(--bg-3); color: var(--fg-0); }

.btn-icon { width: 34px; padding: 0; flex-shrink: 0; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }

/* ===== Inputs ===== */

.input {
  height: 36px; padding: 0 12px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--fg-0);
  font-size: 13px; outline: none;
  transition: border-color 0.12s, box-shadow 0.12s; width: 100%;
}
.input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(139, 124, 255, 0.14); }
.input::placeholder { color: var(--fg-3); }

.select {
  height: 32px; padding: 0 28px 0 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--fg-1); font-size: 12.5px;
  outline: none; appearance: none; width: 100%; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%238a90a3' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color 0.12s;
}
.select:hover { border-color: var(--border-strong); color: var(--fg-0); }
.select:focus { border-color: var(--border-focus); }

/* ===== Tags / Chips ===== */

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
  background: var(--violet-soft); color: var(--violet);
}
.tag-mint { background: var(--mint-soft); color: var(--mint); }
.tag-neutral { background: rgba(255,255,255,0.06); color: var(--fg-1); }

/* ===== Misc atoms ===== */

.kbd {
  display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
  border-radius: 4px; font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-3); color: var(--fg-1);
  border: 1px solid var(--border); border-bottom-width: 2px;
}
.divider { height: 1px; background: var(--border-soft); }
.label-tiny { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
.mono { font-family: var(--font-mono); font-feature-settings: "ss01", "cv01"; }
.h-eyebrow { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-2); font-weight: 600; }
.glow-active { box-shadow: var(--glow-violet); }

/* ===== Code chip ===== */
.code-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: var(--r-sm);
  background: rgba(61, 220, 151, 0.06); border: 1px solid rgba(61, 220, 151, 0.18);
  color: var(--mint); font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: 0.02em; word-break: break-all;
}

/* ===== Drop zones ===== */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: rgba(255,255,255,0.015); transition: all 0.15s ease; }
.dropzone.is-active { border-color: var(--violet); background: var(--violet-soft); box-shadow: var(--glow-violet); }
.dropzone.is-active-mint { border-color: var(--mint); background: var(--mint-soft); box-shadow: var(--glow-mint); }

/* ===== Tabs ===== */
.tabs {
  display: flex; gap: 2px; background: var(--bg-1); padding: 4px;
  border-radius: var(--r-md); border: 1px solid var(--border-soft);
}
.tab {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 500; color: var(--fg-2);
  background: transparent; position: relative; transition: all 0.15s;
  white-space: nowrap;
}
.tab:hover { color: var(--fg-1); }
.tab.active { background: var(--bg-3); color: var(--fg-0); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.tab .badge {
  display: inline-flex; align-items: center; justify-content: center;
  height: 16px; min-width: 16px; padding: 0 5px; border-radius: 8px;
  font-size: 10px; font-weight: 600; background: var(--violet-soft); color: var(--violet-strong);
}
.tab.active .badge { background: var(--violet); color: #0a0c11; }

/* ===== Panels ===== */
.panel {
  background: var(--bg-1); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); display: flex; flex-direction: column; overflow: hidden;
}
.panel-head {
  padding: 12px 14px; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-shrink: 0;
}
.panel-body { flex: 1; overflow: auto; padding: 14px; }
.panel-body.no-pad { padding: 0; }

/* ===== Selector sections ===== */
.sel-section { border: 1px solid var(--border-soft); border-radius: var(--r-md); background: var(--bg-1); overflow: hidden; }
.sel-section + .sel-section { margin-top: 8px; }
.sel-section-head {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
  padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--fg-0);
  letter-spacing: -0.005em;
}
.sel-section-head:hover { background: rgba(255,255,255,0.02); }
.sel-section-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 8px var(--violet); }
.sel-section-body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 8px; }

.sel-field { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: center; }
.sel-field-label { font-size: 12px; color: var(--fg-1); font-weight: 400; }
.sel-field-control { display: flex; gap: 6px; align-items: center; }

/* Read-only description row (green text — pose, accessory, attitude, etc.) */
.sel-detail-row { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: baseline; padding: 2px 0; }
.sel-detail-value { font-size: 11px; color: var(--mint); font-style: italic; line-height: 1.4; }

.sel-pin {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); display: grid; place-items: center;
  color: var(--fg-3); background: transparent; transition: all 0.12s;
}
.sel-pin:hover { color: var(--mint); border-color: var(--mint); }
.sel-pin.locked { color: var(--mint); border-color: var(--mint); background: var(--mint-soft); }

/* ===== Saved strip ===== */
.saved-strip { background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--r-md); padding: 10px; }
.saved-strip-row { display: flex; gap: 8px; align-items: center; overflow-x: auto; padding-bottom: 2px; }
.saved-add {
  flex-shrink: 0; width: 78px; height: 78px; border-radius: 8px;
  border: 1.5px dashed var(--border-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--fg-2); background: transparent; transition: all 0.12s;
}
.saved-add:hover { color: var(--violet); border-color: var(--violet); background: var(--violet-soft); }
.saved-thumb { position: relative; flex-shrink: 0; width: 78px; height: 78px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; }
.saved-thumb img { width: 100%; height: 100%; object-fit: cover; }
.saved-thumb-x {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.7); display: grid; place-items: center;
  color: white; border: 1px solid rgba(255,255,255,0.2); font-size: 11px; line-height: 1;
}
.saved-empty { display: flex; align-items: center; height: 78px; padding: 0 14px; }

/* ===== Prompt area ===== */
.prompt-area {
  position: relative; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-1); overflow: hidden; display: flex; flex-direction: column;
}
.prompt-area.is-drag { border-color: var(--mint); box-shadow: var(--glow-mint); }
.prompt-text {
  flex: 1; padding: 16px 18px; overflow: auto;
  font-size: 12.5px; line-height: 1.6; color: var(--fg-1);
  white-space: pre-wrap; word-break: break-word; user-select: text;
}
.prompt-text .id-line { font-family: var(--font-mono); color: var(--mint); font-size: 11.5px; }
.prompt-text h4 { margin: 14px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--violet); font-weight: 600; }
.prompt-text h4:first-child { margin-top: 0; }

/* ===== Reference cards ===== */
.ref-card {
  border: 1px solid var(--border-soft); border-radius: var(--r-md);
  background: var(--bg-1); overflow: hidden; display: flex; flex-direction: column;
  transition: border-color 0.12s, transform 0.12s;
}
.ref-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.ref-card-img { aspect-ratio: 3/4; position: relative; background: var(--bg-2); overflow: hidden; }
.ref-card-img img { width: 100%; height: 100%; object-fit: cover; }
.ref-card-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }

/* Image placeholder */
.image-ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: repeating-linear-gradient(135deg, rgba(139,124,255,0.08) 0 8px, transparent 8px 16px), var(--bg-2);
  border: 1px solid var(--border-soft);
}

/* ===== Side nav drawer ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 90;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 280px;
  background: var(--bg-1); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform 0.25s ease;
  z-index: 91; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 8px; color: var(--fg-1); text-decoration: none;
  font-size: 13px; font-weight: 500; transition: background 0.12s, color 0.12s;
}
.drawer-link:hover { background: var(--bg-3); color: var(--fg-0); }
.drawer-link.active { background: var(--violet-soft); color: var(--violet-strong); }

/* ===== App shell layout ===== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-0); }
.app-body { flex: 1; display: grid; gap: 14px; padding: 14px 18px 18px; }

.layout-a {
  grid-template-columns: minmax(340px, 420px) 1fr;
  height: calc(100vh - 64px);
  overflow: hidden;
}
.col-scroll { overflow-y: auto; padding-right: 4px; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(10, 12, 17, 0.88); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 18px; display: flex; gap: 16px; align-items: center;
  height: 64px; flex-shrink: 0;
}

/* ===== BAW Logo ===== */
.baw-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex-shrink: 0; }
.baw-logo-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #8b7cff 0%, #6b5ce0 100%);
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(139,124,255,0.35);
  flex-shrink: 0;
}
.baw-logo-text { line-height: 1; }
.baw-logo-title { font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
.baw-logo-sub { font-size: 10px; color: var(--fg-2); letter-spacing: 0.16em; text-transform: uppercase; margin-top: 2px; }

/* ===== Code input wrap ===== */
.code-input-wrap { display: flex; gap: 8px; align-items: center; position: relative; width: 100%; }
.code-input-wrap.drag-image .code-input-field,
.code-input-wrap.drag-text .code-input-field { border-color: var(--violet); }
.code-input-field-wrap { position: relative; flex: 1; display: flex; align-items: center; }
.code-input-icon { position: absolute; left: 12px; color: var(--fg-3); pointer-events: none; }
.code-input-field { padding-left: 34px !important; padding-right: 40px !important; height: 40px !important; font-size: 12.5px !important; letter-spacing: 0.02em; }
.code-input-clear { position: absolute; right: 6px; height: 28px; width: 28px; padding: 0; display: grid; place-items: center; border-radius: 6px; }
.drop-overlay {
  position: absolute; inset: -8px; display: grid; place-items: center;
  background: rgba(10,12,17,0.85); backdrop-filter: blur(6px);
  border-radius: 12px; z-index: 50; pointer-events: none;
  border: 2px dashed var(--violet);
}
.drop-overlay-card {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-radius: 10px; background: var(--bg-1); border: 1px solid var(--border);
  font-size: 13px; color: var(--fg-0);
}
.drop-overlay-card.mint { color: var(--mint); border-color: var(--mint); }
.drop-overlay-card.violet { color: var(--violet); border-color: var(--violet); }

/* ===== Prompt drag overlay ===== */
.prompt-drag-overlay {
  position: absolute; inset: 8px; border-radius: 8px;
  background: rgba(61,220,151,0.1); backdrop-filter: blur(2px);
  display: grid; place-items: center; pointer-events: none; z-index: 5;
  border: 2px dashed var(--mint);
}

/* ===== Summary tab ===== */
.summary-key-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px; background: var(--bg-2); border-radius: 8px; margin-bottom: 12px;
}
.hover-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; }
.hover-row:hover { background: var(--bg-2); }

/* ===== Refs sub-tabs ===== */
.sub-tabs { display: flex; gap: 4px; padding: 3px; background: var(--bg-2); border-radius: 7px; }
.sub-tab {
  padding: 5px 12px; font-size: 11.5px; border-radius: 5px; font-weight: 500;
  color: var(--fg-2); background: transparent; transition: all 0.12s;
}
.sub-tab:hover { color: var(--fg-1); }
.sub-tab.active { background: var(--bg-3); color: var(--fg-0); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }

/* ===== Toast notification ===== */
#v2-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--mint); color: #0a1d14; padding: 10px 18px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; z-index: 200;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 8px 28px rgba(61,220,151,0.3);
  opacity: 0; transition: opacity 0.18s, transform 0.18s; pointer-events: none;
}
#v2-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Lightbox ===== */
#v2-lightbox {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  z-index: 300; align-items: center; justify-content: center;
}
#v2-lightbox.open { display: flex; }
#v2-lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 4px; }
#v2-lightbox-close {
  position: absolute; top: 18px; right: 18px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.1); display: grid; place-items: center; color: white;
}
#v2-lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .layout-a { grid-template-columns: 1fr; height: auto; }
  .topbar { padding: 10px 12px; }
  .app-body { padding: 10px 12px 80px; gap: 10px; }
}

/* ===== Utilities ===== */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hide-scrollbar::-webkit-scrollbar { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
