/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:           #0b0b12;
  --bg-sidebar:   #08080e;
  --bg-card:      #13131c;
  --bg-elevated:  #1b1b26;
  --bg-input:     #17171f;
  --border:       rgba(255,255,255,.07);
  --border-focus: #00d4aa;
  --text:         #eeeef4;
  --text-muted:   #8080a0;
  --text-dim:     #50506a;
  --accent:       #00d4aa;
  --accent-hover: #00bfa0;
  --accent-dim:   rgba(0,212,170,.12);
  --accent-glow:  rgba(0,212,170,.22);
  --danger:       #ef4444;
  --danger-hover: #dc2626;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --radius:       .45rem;
  --radius-lg:    .72rem;
  --shadow:       0 4px 28px rgba(0,0,0,.65);
  --shell-gap:    .65rem;
  --shell-max:    120rem;
  --sidebar-w:    192px;
  --teal:         #14b8a6;
  --teal-dim:     rgba(20,184,166,.15);
  --surface:      var(--bg-card);
  --surface2:     var(--bg-elevated);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(ellipse at 15% 15%, rgba(0,212,170,.07), transparent 28rem),
    radial-gradient(ellipse at 85% 85%, rgba(0,80,200,.05), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: row;
  overflow-x: hidden;
}

/* ── App shell layout ───────────────────────────────────────────────────── */
.app-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── App Sidebar ─────────────────────────────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: sticky;
  top: 0;
  overflow: hidden;
  z-index: 200;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem .72rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 1.85rem;
  height: 1.85rem;
  background: linear-gradient(135deg, var(--accent), #5ef8d8);
  border-radius: .4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  color: #051a14;
  font-weight: 900;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: .04rem;
}

.sidebar-brand-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: .67rem;
  color: var(--text-dim);
  font-weight: 400;
}

.sidebar-primary-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .12rem;
  padding: .58rem .45rem;
  overflow-y: auto;
}

.sidebar-nav-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: .28rem .12rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: .52rem;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: .42rem;
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  font-size: .81rem;
  font-weight: 500;
  padding: .52rem .6rem;
  text-align: left;
  transition: background .15s, color .15s, border-color .15s;
}

.sidebar-nav-item:hover {
  background: rgba(255,255,255,.04);
  color: var(--text-muted);
}

.sidebar-nav-item.active {
  background: rgba(0,212,170,.1);
  border-color: rgba(0,212,170,.18);
  color: var(--accent);
}

.sidebar-nav-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  stroke: currentColor;
}

.sidebar-nav-label {
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-footer {
  padding: .45rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  gap: .12rem;
  flex-shrink: 0;
}

.runtime-stats-mini {
  font-size: .68rem;
  color: var(--text-dim);
  padding: .18rem .52rem .28rem;
  line-height: 1.45;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: rgba(11,11,18,.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,.06);
  padding: .5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.header-workflow-label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: .28rem;
}

.header-icon-btn {
  width: 1.9rem;
  height: 1.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: .4rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}

.header-icon-btn:hover {
  background: rgba(255,255,255,.06);
  color: var(--text-muted);
  border-color: rgba(255,255,255,.08);
}

.header-icon-btn svg {
  width: .92rem;
  height: .92rem;
}

.header-icon-btn-avatar {
  background: var(--bg-elevated);
  border-color: rgba(255,255,255,.1);
}

/* ── Tab nav (assets sub-tabs) ───────────────────────────────────────────── */
.tab-nav { display: none; }

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  font-size: .875rem;
  font-weight: 500;
  padding: .65rem 1rem;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Main ────────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  overflow: visible;
  padding-bottom: 1.5rem;
}

.tab-panel {
  display: none;
  padding: .45rem .55rem .75rem;
  max-width: none;
  margin: 0 auto;
  animation: fadeIn .15s ease;
}
.tab-panel.active { display: block; }

.studio-workbench {
  display: grid;
  grid-template-columns: minmax(380px, 1.05fr) minmax(320px, 1fr);
  gap: var(--shell-gap);
  max-width: var(--shell-max);
  width: 100%;
  align-items: start;
  margin: 0 auto;
  padding: .25rem 0;
}

.workbench-gallery,
.workbench-nav,
.workbench-controls,
.workbench-preview {
  min-width: 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .95fr);
  gap: .7rem;
  align-items: start;
}

.library-grid {
  max-width: 140rem;
  margin: 0 auto;
}

.workspace-main,
.workspace-side {
  min-width: 0;
}

.workspace-side-sticky {
  position: sticky;
  top: 3.5rem;
}

@media (min-width: 1101px) {
  .workflow-section.active > .card,
  .workbench-preview #active-generation > .card:not(.workflow-preview-card) {
    min-height: calc(100dvh - 3.5rem);
  }

  .studio-workbench.workflow-focused {
    grid-template-columns: 1fr;
    max-width: 100%;
    padding: 0;
  }

  .studio-workbench.workflow-focused .workbench-preview {
    display: none;
  }

  .studio-workbench.workflow-focused .workbench-controls {
    min-width: 0;
    max-width: 100%;
  }
}

.compact-header {
  margin-bottom: .5rem;
}

.compact-card {
  padding: .7rem .8rem;
}

.workbench-controls .card,
.workbench-preview .card,
.asset-library-content .card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.018), rgba(255,255,255,.008)),
    var(--bg-card);
  border-color: rgba(255,255,255,.07);
}

.section-sidebar .card,
.section-sidebar.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.015)),
    var(--bg-card);
}

.sidebar-intro {
  margin-top: .25rem;
  margin-bottom: .6rem;
  font-size: .79rem;
  line-height: 1.45;
}

.workflow-switcher {
  margin-bottom: .6rem;
}

.workflow-tab-list {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.workflow-tab-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  padding: .42rem .72rem;
}

.workflow-tab-btn.active {
  background: var(--accent-dim);
  border-color: rgba(0,212,170,.45);
  color: var(--text);
}

.workflow-sidebar-list {
  display: grid;
  gap: .45rem;
}

.sidebar-nav {
  display: grid;
  gap: .45rem;
}

.sidebar-nav-btn {
  display: grid;
  gap: .18rem;
  justify-items: start;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font: inherit;
  min-height: 0;
  padding: .55rem .65rem;
  text-align: left;
  transition: border-color .15s, background .15s, color .15s;
  width: 100%;
}

.sidebar-nav-btn:hover {
  border-color: rgba(0,212,170,.25);
  color: var(--text);
}

.sidebar-nav-btn.active {
  background: rgba(0,212,170,.1);
  border-color: rgba(0,212,170,.22);
  color: var(--accent);
}

.sidebar-nav-btn-title {
  font-size: .84rem;
  font-weight: 700;
  color: inherit;
}

.sidebar-nav-btn-meta {
  color: var(--text-dim);
  font-size: .71rem;
  font-weight: 500;
  line-height: 1.35;
}

.sidebar-nav-btn.active .sidebar-nav-btn-meta {
  color: var(--text-muted);
}

.workflow-section {
  display: none;
}

.workflow-section.active {
  display: block;
}

.workflow-source-shell {
  display: grid;
  gap: .65rem;
  margin-bottom: .65rem;
}

.workflow-source-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: var(--shell-gap);
}

.workflow-source-card,
.workflow-source-browser,
.workflow-stage-card,
.workflow-subsection {
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.012)),
    var(--bg-card);
}

.workflow-stage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .85rem;
}

.workflow-shell-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, .82fr);
  gap: var(--shell-gap);
  align-items: start;
}

.workflow-shell-main,
.workflow-shell-side {
  min-width: 0;
}

.workflow-shell-side {
  display: grid;
  gap: .75rem;
}

/* ── Full-screen workflow panel (Edit / Upscale) ────────────────────────────── */
.wf-panel {
  display: grid;
  grid-template-columns: 1fr 360px;
  height: calc(100dvh - 3.5rem);
  overflow: hidden;
}

.wf-canvas-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #080810;
  border-right: 1px solid rgba(255,255,255,.08);
  min-width: 0;
}

.wf-controls-col {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg-card);
  border-left: 1px solid rgba(255,255,255,.09);
  min-width: 0;
  overflow-x: hidden;
}

.wf-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
  padding: .45rem .65rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.wf-toolbar-sep {
  width: 1px;
  height: 1.4rem;
  background: rgba(255,255,255,.12);
  margin: 0 .15rem;
  flex-shrink: 0;
}

.wf-toolbar-label {
  font-size: .75rem;
  color: var(--text-dim);
  margin: 0;
  white-space: nowrap;
}

.wf-toolbar-range {
  width: 5.5rem;
  accent-color: var(--accent);
}

.wf-canvas-stage,
.wf-image-stage {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.wf-canvas-stage .edit-mask-wrap {
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.wf-canvas-stage .edit-mask-canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 3.5rem - 2.8rem);
  display: block;
  cursor: crosshair;
}

.wf-image-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.wf-canvas-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}

.wf-source-chip {
  padding: .55rem .75rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  font-size: .82rem;
}

.wf-source-chip .card-title {
  font-size: .85rem;
}

.wf-source-chip .card-meta {
  font-size: .78rem;
}

.wf-source-chip .gen-output-img {
  display: none;
}

.wf-source-chip .card-header {
  gap: .5rem;
  margin-bottom: 0;
}

.wf-source-chip .card-actions {
  gap: .3rem;
}

.wf-source-drawer {
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.wf-source-drawer-summary {
  padding: .45rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.wf-source-drawer-summary::-webkit-details-marker { display: none; }

.wf-source-drawer-summary::before {
  content: '▸ ';
  font-size: .7rem;
}

details.wf-source-drawer[open] .wf-source-drawer-summary::before {
  content: '▾ ';
}

.wf-drawer-list {
  max-height: 13rem;
  overflow-y: auto;
  padding: .3rem .5rem .5rem;
}

.wf-section {
  padding: .7rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.wf-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}

.wf-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin-bottom: .45rem;
}

.wf-section-actions {
  display: flex;
  gap: .25rem;
  align-items: center;
  flex-wrap: wrap;
}

.wf-section-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .45rem;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .wf-panel {
    grid-template-columns: 1fr;
    grid-template-rows: min(55vw, 50dvh) 1fr;
    height: auto;
  }

  .wf-canvas-col {
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,.08);
    height: min(55vw, 50dvh);
  }

  .wf-controls-col {
    border-left: none;
    max-height: 60dvh;
  }
}

.workflow-subsection {
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  padding: .8rem;
}

.workflow-section-copy {
  max-width: 40rem;
}

.section-title-sm {
  font-size: .92rem;
  margin-bottom: .15rem;
}

.workflow-source-list {
  display: grid;
  gap: .5rem;
  max-height: min(38rem, 52dvh);
  overflow: auto;
  padding-right: .15rem;
}

.workflow-source-choice {
  display: grid;
  grid-template-columns: 4.75rem minmax(0, 1fr) auto;
  gap: .7rem;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: .55rem;
  transition: border-color .15s, background .15s, transform .1s;
}

.workflow-source-choice:hover {
  border-color: rgba(0,212,170,.4);
  transform: translateY(-1px);
}

.workflow-source-choice.active {
  background: linear-gradient(180deg, rgba(0,212,170,.16), rgba(0,212,170,.06)), var(--bg-input);
  border-color: rgba(0,212,170,.55);
}

.workflow-source-thumb {
  width: 4.75rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: .65rem;
  border: 1px solid rgba(255,255,255,.08);
  background: var(--bg-elevated);
}

.workflow-source-copy {
  display: grid;
  gap: .15rem;
  min-width: 0;
}

.workflow-source-title {
  font-size: .84rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workflow-source-meta {
  font-size: .73rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workflow-source-pill {
  font-size: .72rem;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  padding: .18rem .5rem;
}

.workflow-preview-card {
  display: grid;
  gap: .55rem;
}

.workflow-preview-steps {
  display: grid;
  gap: .45rem;
  margin-top: .1rem;
}

.workflow-preview-step {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .45rem;
  align-items: start;
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.45;
}

.workflow-preview-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: rgba(0,212,170,.16);
  border: 1px solid rgba(0,212,170,.24);
  color: var(--text);
  font-size: .72rem;
  font-weight: 700;
}

.assets-tab-section {
  display: none;
}

.assets-tab-section.active {
  display: block;
}

.asset-library-layout {
  display: grid;
  grid-template-columns: minmax(204px, 220px) minmax(0, 1fr);
  gap: var(--shell-gap);
  align-items: start;
  max-width: var(--shell-max);
  margin: 0 auto;
}

.asset-library-sidebar {
  position: sticky;
  top: 3.5rem;
}

.asset-library-content {
  min-width: 0;
}

.asset-library-panel {
  display: none;
}

.asset-library-panel.active {
  display: block;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 32px rgba(0,0,0,.22);
  padding: .8rem .85rem;
  margin-bottom: .55rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: .5rem;
}
.card-title { font-weight: 600; font-size: .95rem; }
.card-meta  { font-size: .78rem; color: var(--text-muted); line-height: 1.5; margin-top: .18rem; }
.card-actions { display: flex; gap: .4rem; flex-shrink: 0; }

.consistency-card {
  margin-bottom: .55rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  justify-content: center;
  padding: .5rem 1rem;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-elevated); border-color: var(--text-dim); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

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

.btn-sm  { font-size: .8rem; padding: .3rem .7rem; }
.btn-full { width: 100%; }

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,.1); border-color: var(--danger); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: .75rem; }
.form-label  { display: block; font-size: .82rem; font-weight: 500; color: var(--text-muted); margin-bottom: .3rem; }
.form-hint   { font-weight: 400; color: var(--text-dim); font-size: .78rem; }

.form-input,
.form-select,
.form-textarea {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
  padding: .55rem .7rem;
  transition: border-color .15s;
  width: 100%;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { outline: none; border-color: var(--border-focus); }

.form-textarea { resize: vertical; min-height: 72px; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  padding-right: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
}
.form-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 440px) { .form-row { grid-template-columns: 1fr; } }

@media (max-width: 980px) {
  .library-grid {
    grid-template-columns: 1fr;
  }

  .asset-library-layout {
    grid-template-columns: 1fr;
  }

  .asset-library-sidebar {
    position: static;
  }

  .asset-library-nav {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem;
}
.form-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* ── Prompt preview ──────────────────────────────────────────────────────── */
.prompt-preview-details {
  margin-bottom: .7rem;
}
.prompt-preview-summary {
  cursor: pointer;
  font-size: .78rem;
  color: var(--text-dim);
  user-select: none;
  padding: .25rem 0;
}
.prompt-preview-summary:hover { color: var(--text-muted); }
.prompt-preview-text {
  margin-top: .4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: inherit;
  font-size: .78rem;
  line-height: 1.6;
  padding: .6rem .75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.refine-chat-thread {
  display: grid;
  gap: .6rem;
  max-height: 18rem;
  overflow: auto;
}

.refine-chat-bubble {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .8rem;
  font-size: .84rem;
}

.refine-chat-bubble.user {
  border-color: rgba(0,212,170,.32);
}

.refine-chat-bubble.assistant {
  border-color: rgba(255,255,255,.08);
}

.refine-chat-role {
  color: var(--text-dim);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: .3rem;
  text-transform: uppercase;
}

.copilot-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 120;
}

/* ── Runtime panel ───────────────────────────────────────────────────────── */
.runtime-status-dot {
  width: .52rem;
  height: .52rem;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: auto;
}
.runtime-dot-idle    { background: var(--text-dim); }
.runtime-dot-running { background: var(--warning); box-shadow: 0 0 5px var(--warning); }
.runtime-dot-error   { background: var(--danger);  box-shadow: 0 0 5px var(--danger); }

.runtime-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
}

.runtime-panel {
  position: fixed;
  left: var(--sidebar-w);
  bottom: 0;
  width: min(26rem, calc(100vw - var(--sidebar-w)));
  max-height: min(34rem, 90dvh);
  overflow-y: auto;
  z-index: 295;
  background: var(--bg-elevated);
  border: 1px solid rgba(255,255,255,.1);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -6px 36px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  transition: transform .2s ease, opacity .15s ease;
}

.runtime-panel.hidden {
  display: none;
}

.runtime-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}

.runtime-panel-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}

.runtime-panel-body {
  padding: .8rem .9rem;
  flex: 1;
}

.runtime-panel-body .card-title {
  font-size: .88rem;
}

.runtime-kill-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .65rem 0;
  padding: .65rem;
  background: rgba(239,68,68,.06);
  border: 1px solid rgba(239,68,68,.18);
  border-radius: var(--radius);
}

.runtime-kill-row .btn {
  flex: 1;
}

@media (max-width: 720px) {
  .runtime-panel {
    left: 0;
    width: 100%;
    max-height: 80dvh;
  }
}

.copilot-panel {
  position: fixed;
  right: 1rem;
  bottom: 4.5rem;
  width: min(30rem, calc(100vw - 2rem));
  max-height: min(42rem, calc(100dvh - 6rem));
  overflow: auto;
  z-index: 120;
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.015)),
    var(--bg-card);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: .9rem;
}

.copilot-header {
  align-items: flex-start;
  display: flex;
  gap: .75rem;
  justify-content: space-between;
}

.copilot-thread {
  display: grid;
  gap: .6rem;
  margin-top: .8rem;
  max-height: 18rem;
  overflow: auto;
  padding-right: .1rem;
}

.reference-choice-grid {
  display: grid;
  gap: .55rem;
  max-height: 18rem;
  overflow: auto;
}

.reference-choice {
  display: grid;
  grid-template-columns: auto 4rem 1fr;
  gap: .65rem;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem;
}

.reference-choice input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.reference-choice img,
.reference-preview-strip img {
  width: 4rem;
  height: 4rem;
  object-fit: cover;
  border-radius: .45rem;
  border: 1px solid var(--border);
}

.reference-preview-strip {
  display: flex;
  gap: .45rem;
  overflow: auto;
  margin-top: .55rem;
  padding-bottom: .2rem;
}

.asset-group + .asset-group {
  margin-top: .75rem;
}

.workflow-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .75rem;
  overflow: hidden;
}

.workflow-summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 600;
  list-style: none;
  padding: .62rem .75rem;
  user-select: none;
}

.workflow-summary::-webkit-details-marker {
  display: none;
}

.workflow-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: .45rem;
  transition: transform .15s ease;
}

.workflow-details[open] .workflow-summary::before {
  transform: rotate(90deg);
}

.workflow-details-body {
  border-top: 1px solid rgba(255,255,255,.05);
  padding: .68rem .75rem .05rem;
}

/* ── Section header ──────────────────────────────────────────────────────── */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.section-title  { font-size: 1.02rem; font-weight: 650; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .2rem .55rem;
  text-transform: uppercase;
}
.badge-pending { background: rgba(161,161,170,.12); color: var(--text-muted); }
.badge-running { background: rgba(245,158,11,.15);  color: var(--warning); }
.badge-done    { background: rgba(34,197,94,.12);   color: var(--success); }
.badge-error   { background: rgba(239,68,68,.12);   color: var(--danger); }
.badge-canceled { background: rgba(148,163,184,.18); color: #cbd5e1; }

/* ── Active generation card ──────────────────────────────────────────────── */
.gen-status-card { margin-bottom: .75rem; }
.gen-status-card.status-running { border-color: rgba(245,158,11,.35); }
.gen-status-card.status-done    { border-color: rgba(34,197,94,.3); }
.gen-status-card.status-error   { border-color: rgba(239,68,68,.3); }

.gen-output-img {
  width: 100%;
  max-height: min(70dvh, 760px);
  object-fit: contain;
  border-radius: var(--radius);
  margin-top: .65rem;
  cursor: pointer;
  display: block;
}

/* ── Recent generations list ─────────────────────────────────────────────── */
.recent-card { cursor: pointer; }
.recent-card:hover { border-color: var(--accent); }

.recent-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius);
  flex-shrink: 0;
  background: var(--bg-input);
}
.recent-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--bg-input);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 1.1rem;
}

/* ── Gallery grid ────────────────────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: .5rem;
}

.gallery-toolbar {
  align-items: center;
  display: grid;
  gap: .5rem;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto;
  margin-bottom: .7rem;
}

.gallery-toolbar-actions {
  display: flex;
  gap: .5rem;
}

.compact-gallery {
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  max-height: calc(100dvh - 5.6rem);
  overflow: auto;
  padding-right: .2rem;
}
@media (max-width: 440px) { .gallery-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 1100px) {
  .studio-workbench {
    grid-template-columns: 1fr;
    padding: .15rem 0;
  }

  .compact-gallery {
    max-height: none;
    overflow: visible;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .workspace-side-sticky {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-sidebar {
    width: 100%;
    height: auto;
    min-height: 0;
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid rgba(255,255,255,.08);
    z-index: 300;
  }

  .sidebar-brand,
  .sidebar-footer,
  .sidebar-nav-divider,
  .sidebar-nav-label,
  .sidebar-brand-text,
  .runtime-stats-mini {
    display: none;
  }

  .sidebar-primary-nav {
    flex-direction: row;
    padding: .35rem .3rem;
    gap: .1rem;
    justify-content: space-around;
    flex: 1;
    overflow: visible;
  }

  .sidebar-nav-item {
    flex-direction: column;
    gap: .2rem;
    padding: .4rem .5rem;
    align-items: center;
    justify-content: center;
    flex: 1;
    font-size: .65rem;
  }

  .sidebar-nav-label {
    display: block;
    overflow: visible;
    font-size: .65rem;
  }

  .app-content {
    padding-bottom: 3.5rem;
  }
}

.gallery-item {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s, transform .1s;
}
.gallery-item:hover { border-color: var(--accent); transform: scale(1.02); }

.gallery-media {
  position: relative;
}

.gallery-img {
  aspect-ratio: 1;
  background: var(--bg-input);
  display: block;
  object-fit: cover;
  width: 100%;
}
.gallery-info { padding: .42rem .55rem .52rem; }
.gallery-name { font-size: .78rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-time { color: var(--text-dim); font-size: .7rem; margin-top: .1rem; }
.gallery-meta-row {
  align-items: center;
  display: flex;
  gap: .35rem;
  margin-top: .35rem;
}
.gallery-chip {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  display: inline-flex;
  font-size: .68rem;
  padding: .15rem .45rem;
}
.gallery-chip-favorite {
  color: #fbbf24;
}
.gallery-menu-trigger {
  align-items: center;
  background: rgba(7, 10, 16, .82);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  font-size: 1rem;
  height: 2rem;
  justify-content: center;
  position: absolute;
  right: .5rem;
  top: .5rem;
  width: 2rem;
  z-index: 2;
}
.gallery-menu-trigger:hover {
  background: rgba(24, 29, 42, .95);
}
.gallery-context-menu {
  background: rgba(14, 18, 26, .98);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  min-width: 10rem;
  padding: .3rem;
  position: absolute;
  right: .5rem;
  top: 3rem;
  z-index: 3;
}
.gallery-context-menu.open {
  display: grid;
  gap: .2rem;
}
.gallery-context-item {
  background: transparent;
  border: 0;
  border-radius: .45rem;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  padding: .45rem .55rem;
  text-align: left;
}
.gallery-context-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--text-main);
}
.gallery-context-item:disabled {
  cursor: default;
  opacity: .55;
}
.gallery-tags {
  color: var(--text-muted);
  font-size: .7rem;
  line-height: 1.35;
  margin-top: .35rem;
  min-height: 1.8em;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  animation: spin .75s linear infinite;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  height: 1rem;
  width: 1rem;
}
.spinner-lg { width: 2rem; height: 2rem; border-width: 3px; }

/* ── Progress bar ────────────────────────────────────────────────────────── */
.progress-bar {
  background: var(--bg-input);
  border-radius: 2px;
  height: 3px;
  margin-top: .6rem;
  overflow: hidden;
}
@keyframes pulseProg { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
.progress-fill {
  animation: pulseProg 1.8s ease-in-out infinite;
  background: var(--accent);
  border-radius: 2px;
  height: 100%;
  width: 35%;
  transition: width .35s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .6rem;
  margin-top: .45rem;
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Flex helpers ────────────────────────────────────────────────────────── */
.flex-center { display: flex; align-items: center; gap: .5rem; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: .75rem;
  padding: .7rem 1rem;
}
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.3);  color: #86efac; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state { color: var(--text-muted); padding: 2.5rem 1rem; text-align: center; }
.empty-state-icon { font-size: 2.2rem; margin-bottom: .65rem; }
.empty-state-text { font-size: .875rem; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  align-items: flex-end;
  background: rgba(0,0,0,.75);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 200;
}
@media (min-width: 600px) { .modal-overlay { align-items: center; } }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius) var(--radius);
  box-shadow: var(--shadow);
  max-height: 90dvh;
  max-width: 30rem;
  overflow-y: auto;
  padding: 1.25rem;
  width: 100%;
}
@media (min-width: 600px) { .modal-box { border-radius: var(--radius-lg); } }

.modal-title   { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

.gallery-modal-collections {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  gap: .45rem;
  margin-top: .5rem;
  max-height: 14rem;
  overflow-y: auto;
  padding: .65rem;
}

@media (max-width: 900px) {
  .gallery-toolbar {
    grid-template-columns: 1fr;
  }

  .gallery-toolbar-actions {
    justify-content: flex-start;
  }
}

.interrogation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.interrogation-section {
  margin-top: .9rem;
}

.interrogation-tag-list {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 12rem;
  overflow-y: auto;
  padding: .35rem .5rem;
}

.interrogation-tag-row {
  align-items: center;
  display: flex;
  font-size: .85rem;
  gap: .75rem;
  justify-content: space-between;
  padding: .28rem 0;
}

.interrogation-tag-row + .interrogation-tag-row {
  border-top: 1px solid rgba(255,255,255,.05);
}

.interrogation-tag-name {
  color: var(--text);
}

.interrogation-tag-score {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */
.lightbox {
  align-items: center;
  background: rgba(0,0,0,.96);
  display: flex;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 300;
}
.lightbox-img {
  border-radius: var(--radius);
  max-height: 82dvh;
  max-width: 100%;
  object-fit: contain;
}
.lightbox-close {
  background: rgba(255,255,255,.1);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: .4rem .6rem;
  position: absolute;
  right: 1rem;
  top: 1rem;
}
.lightbox-close:hover { background: rgba(255,255,255,.2); }
.lightbox-info {
  color: var(--text-muted);
  font-size: .82rem;
  margin-top: .8rem;
  max-width: 600px;
  text-align: center;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Face preview panel ──────────────────────────────────────────────────── */
.face-preview-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.face-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .75rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.face-preview-title {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.face-overlay-wrap {
  background: #000;
  line-height: 0;
}
.face-overlay-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
}
.face-list {
  padding: .5rem .6rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.face-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .5rem;
  background: var(--bg-elevated);
  border-radius: calc(var(--radius) - 2px);
  font-size: .8125rem;
}
.face-item-badge {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .625rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.face-item .form-check { flex: 1; margin: 0; }
.face-item-size-select { width: 5rem; font-size: .8125rem; }
.face-item-dims {
  font-size: .6875rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.face-no-faces {
  padding: .5rem .75rem;
  font-size: .8125rem;
  color: var(--text-muted);
}

.edit-foundation-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1rem;
}
.edit-foundation-header,
.edit-foundation-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.edit-foundation-header {
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}
.edit-foundation-actions {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.edit-foundation-toolbar {
  flex-wrap: wrap;
}
.edit-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: .85rem;
  align-items: start;
}
.edit-mask-wrap {
  background: #000;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.edit-mask-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}
.edit-layer-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  padding: .7rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.edit-layer-panel-header,
.edit-layer-item,
.edit-layer-panel-actions {
  display: flex;
  align-items: center;
}
.edit-layer-panel-header {
  justify-content: space-between;
  gap: .5rem;
}
.edit-layer-panel-actions {
  gap: .35rem;
}
.edit-layer-list {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.edit-layer-item {
  gap: .45rem;
  padding: .45rem .5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.edit-layer-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.edit-layer-item button {
  flex: 1;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.edit-layer-item input[type="checkbox"] {
  margin: 0;
}
.edit-layer-panel-footer {
  padding-top: .2rem;
  border-top: 1px solid var(--border);
}
.edit-lineage-info {
  padding: .6rem .75rem;
  font-size: .8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.lineage-chip {
  padding: .18rem .45rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
@media (max-width: 980px) {
  .workflow-source-grid,
  .workflow-shell-grid {
    grid-template-columns: 1fr;
  }

  .workflow-source-list {
    max-height: none;
  }

  .workflow-source-choice {
    grid-template-columns: 4rem minmax(0, 1fr);
  }

  .workflow-source-pill {
    display: none;
  }

  .workflow-preview-card {
    gap: .45rem;
  }

  .workflow-preview-steps {
    gap: .35rem;
  }

  .workflow-preview-step {
    font-size: .78rem;
  }

  .edit-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workflow-switcher {
    margin-bottom: .5rem;
  }

  .sidebar-nav {
    gap: .35rem;
  }

  .sidebar-nav-btn {
    padding: .58rem .65rem;
  }

  .sidebar-nav-btn-meta {
    font-size: .68rem;
    line-height: 1.28;
  }

  .workflow-preview-card .card-meta {
    margin-bottom: .05rem;
  }

  .workflow-preview-steps {
    display: none;
  }
}

/* ── Auth overlay ────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.auth-overlay.hidden { display: none; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%; max-width: 400px;
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); margin-top: .5rem; }
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1; padding: .6rem 1rem; background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: .875rem; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.auth-tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.auth-form { display: flex; flex-direction: column; gap: .875rem; }
.auth-field { display: flex; flex-direction: column; gap: .3rem; }
.auth-field label { font-size: .8rem; color: var(--text-dim); font-weight: 500; }
.auth-field input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: .5rem .75rem; color: var(--text); font-size: .875rem;
  transition: border-color .15s;
}
.auth-field input:focus { outline: none; border-color: var(--teal); }
.auth-error {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border: 1px solid var(--danger); border-radius: 6px;
  padding: .5rem .75rem; font-size: .8rem; color: var(--danger);
}
.auth-error.hidden { display: none; }
.auth-pending-msg {
  text-align: center; padding: 1rem; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.auth-pending-msg svg { width: 48px; height: 48px; color: var(--warning); }
.btn-full { width: 100%; justify-content: center; }

/* ── User menu ───────────────────────────────────────────────────────────── */
.user-menu { position: relative; }
.user-menu-trigger {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: .375rem .625rem; cursor: pointer; color: var(--text);
  font-size: .8rem; font-weight: 500; transition: background .15s, border-color .15s;
}
.user-menu-trigger:hover { background: var(--surface2); border-color: var(--teal-dim); }
.user-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; flex-shrink: 0;
}
.user-menu-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 200;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); min-width: 160px; overflow: hidden;
}
.user-menu-dropdown.hidden { display: none; }
.user-menu-item {
  display: block; width: 100%; text-align: left;
  padding: .5rem .875rem; background: none; border: none;
  color: var(--text); font-size: .8rem; cursor: pointer;
  font-family: inherit; transition: background .1s;
}
.user-menu-item:hover { background: var(--surface2); }
.user-menu-item--danger { color: var(--danger); }
.user-menu-divider { height: 1px; background: var(--border); margin: .25rem 0; }

/* ── Admin panel ─────────────────────────────────────────────────────────── */
.admin-user-list { display: flex; flex-direction: column; gap: .5rem; }
.admin-user-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .75rem; background: var(--bg); border-radius: 6px;
  border: 1px solid var(--border);
}
.admin-user-row .user-info { flex: 1; min-width: 0; }
.admin-user-row .user-name { font-weight: 600; font-size: .875rem; }
.admin-user-row .user-meta { font-size: .75rem; color: var(--text-dim); }
.admin-user-actions { display: flex; gap: .4rem; flex-shrink: 0; flex-wrap: wrap; }
.badge-pending {
  background: color-mix(in srgb, var(--warning) 20%, transparent);
  color: var(--warning); border-radius: 4px; padding: .15rem .4rem;
  font-size: .7rem; font-weight: 600;
}
.badge-admin {
  background: color-mix(in srgb, var(--teal) 20%, transparent);
  color: var(--teal); border-radius: 4px; padding: .15rem .4rem;
  font-size: .7rem; font-weight: 600;
}

/* ── Standalone modal (change-password, etc.) ────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 440px;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; margin: 0; }
.modal-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 1.25rem; cursor: pointer; padding: 0 .25rem; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex; gap: .5rem; justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

