/* ==========================================================================
   Rampage444 IT — User Studio Layout & Components
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  background-image: var(--bg-canvas-glow);
  background-attachment: fixed;
}

/* --- Sidebar --- */
.sidebar {
  position: sticky;
  inset-block-start: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-inline-end: 1px solid var(--border-subtle);
  padding: 16px 14px;
  z-index: 40;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 18px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--glass-primary-bg);
  color: var(--accent-on);
  font-weight: 800;
  font-size: 17px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: var(--glass-glow), var(--glass-specular);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-section-title {
  margin: 8px 8px 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  text-align: start;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-btn:hover:not(.is-active) {
  background: var(--bg-surface-hover);
  color: var(--accent-text);
}

.nav-btn.is-active {
  background: var(--bg-nav-active);
  border-color: transparent;
  box-shadow: inset 3px 0 0 var(--nav-active-bar);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-count {
  margin-inline-start: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.nav-btn.is-active .nav-count {
  background: var(--accent-soft-strong);
  color: var(--accent-text);
}

/* Sidebar Footer Access Card */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.access-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--bg-access-card);
  border: 1px solid var(--border-access-card);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.access-card-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.access-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-heading);
}

.access-card-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.access-key-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-text);
  letter-spacing: 0.04em;
}

.access-card-btn {
  margin-top: 7px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-access-btn);
  background: var(--bg-access-btn);
  color: var(--accent-text);
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.access-card-btn:hover {
  background: var(--bg-access-btn-hover);
  border-color: var(--border-gold-strong);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

.access-card-btn:active {
  transform: translateY(0);
}

.access-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.btn-ghost-sm {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.btn-ghost-sm:hover:not(:disabled) {
  background: var(--glass-bg-hover);
  border-color: var(--border-gold-strong);
  color: var(--accent-text);
  transform: translateY(-1px);
}

.btn-ghost-sm:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.admin-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.admin-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.admin-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-copyright {
  padding: 2px 10px 0;
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Main Area --- */
.workspace-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
  overflow-x: clip;
}

.topbar {
  position: sticky;
  inset-block-start: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 30;
}

.theme-toggle-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-gold);
  background: var(--bg-surface-elevated);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.theme-toggle-btn:hover {
  background: var(--bg-nav-active);
  border-color: var(--border-gold-strong);
  transform: translateY(-1px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  align-items: center;
  justify-content: center;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  font-size: 13px;
  color: var(--text-muted);
}

.breadcrumbs strong {
  color: var(--text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 7px;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--text-primary);
}

.status-pill-btn {
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.status-pill-btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--border-gold-strong);
  transform: translateY(-1px);
}

.status-dot {
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.is-online {
  background: var(--status-success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.65);
}

.status-dot.is-busy {
  background: var(--status-warning);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.content-wrap {
  flex: 1;
  padding: 20px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1600px;
  width: 100%;
  margin-inline: auto;
}

/* --- Prompt Composer --- */
.composer-shell {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow-composer);
  overflow: hidden;
}

.composer-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 14px;
}

.composer-shell.is-locked .composer-form {
  opacity: 0.18;
  filter: blur(2px);
  pointer-events: none;
}

.composer-lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-composer-lock);
  text-align: center;
  padding: 16px;
}

.composer-lock-overlay[hidden] {
  display: none;
}

.composer-lock-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.prompt-textarea {
  width: 100%;
  min-height: 54px;
  max-height: 200px;
  resize: vertical;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  padding: 0;
}

.prompt-textarea::placeholder {
  color: var(--text-muted);
}

.prompt-textarea:focus {
  outline: none;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.param-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.param-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.param-chip.is-relax {
  background: var(--accent-soft);
  border-color: var(--border-gold);
  color: var(--accent-text);
  font-weight: 600;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 12px rgba(0, 0, 0, 0.18);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease, color 0.16s ease;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--glass-bg-hover);
  border-color: var(--border-gold-strong);
  color: var(--accent-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.26), 0 6px 18px rgba(16, 185, 129, 0.2);
  transform: translateY(-1px);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(110, 231, 183, 0.65);
  background: var(--glass-primary-bg);
  color: var(--accent-on);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: var(--glass-glow), var(--glass-specular);
  transition: filter 0.16s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.07);
  box-shadow: var(--glass-glow-hover), inset 0 1px 0 rgba(255, 255, 255, 0.52);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.24);
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* --- Native Popover Settings Panel --- */
.params-popover {
  inset: auto;
  margin: 0;
  position: fixed;
  inset-block-start: 146px;
  inset-inline-end: 28px;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--bg-dialog);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
}

.params-popover:not(:popover-open):not(.\:popover-open) {
  display: none;
}

.params-popover:where(:popover-open, .\:popover-open) {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.popover-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.param-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.param-label-row strong {
  color: var(--accent-text);
  font-family: var(--font-mono);
}

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.choice-pill {
  padding: 7px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.choice-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.choice-pill.is-selected {
  background: var(--accent-soft-strong);
  border-color: var(--accent);
  color: var(--accent-text);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.range-input {
  width: 100%;
  cursor: pointer;
}

/* --- Gallery Toolbar --- */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.gallery-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.gallery-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.gallery-count {
  font-size: 12.5px;
  color: var(--text-muted);
}

.gallery-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 236px;
  padding: 8px 13px 8px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 13.5px;
  color: var(--text-primary);
}

.search-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.search-icon {
  position: absolute;
  inset-inline-start: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-secondary);
  pointer-events: none;
}

.filter-select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

.density-group {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
}

.density-btn {
  width: 30px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}

.density-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* --- Gallery Grid & Empty State --- */
.empty-state {
  flex: 1;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

.empty-state[hidden] {
  display: none;
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: var(--accent-soft);
  border: 1px solid var(--border-gold);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.empty-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-sub {
  margin: 0;
  max-width: 380px;
  font-size: 13px;
  color: var(--text-secondary);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(265px, 100%), 1fr));
  gap: 16px;
}

.gallery-grid.density-sm {
  grid-template-columns: repeat(auto-fill, minmax(min(195px, 100%), 1fr));
}

.gallery-grid.density-lg {
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
}

.gen-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.gen-card:hover {
  border-color: var(--border-gold);
}

.gen-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-input);
  overflow: hidden;
}

.gen-media-btn {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  display: block;
}

.gen-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gen-pending-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  text-align: center;
  background: linear-gradient(125deg, var(--bg-input) 25%, var(--bg-surface-elevated) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 2.2s infinite linear;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.gen-progress-ring {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-text);
}

.gen-progress-bar {
  width: 72%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.gen-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #059669, #34d399);
  transition: width 0.35s ease;
}

.gen-status-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.gen-failed-box {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
  background: rgba(239, 91, 91, 0.06);
}

.gen-failed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--status-danger);
}

.gen-failed-reason {
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-word;
}

.gen-badge-top {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-start: 10px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: rgba(15, 13, 10, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-text);
  backdrop-filter: blur(6px);
}

.gen-fav-btn {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 13, 10, 0.75);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.gen-fav-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-gold);
}

.gen-fav-btn.is-fav {
  color: #f45b69;
  border-color: rgba(244, 91, 105, 0.5);
  background: rgba(244, 91, 105, 0.16);
}

.gen-body {
  padding: 11px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gen-prompt {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gen-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mj-action-btn {
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 700;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.mj-action-btn:hover:not(:disabled) {
  background: var(--accent-soft-strong);
  border-color: var(--accent);
  color: var(--accent-text);
  transform: translateY(-1px);
}

.mj-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.gen-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Native Modal Dialogs --- */
.modal-dialog {
  width: min(460px, calc(100vw - 24px));
  padding: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-gold);
  background: var(--bg-dialog);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

.modal-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.modal-benefits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 4px;
}

.modal-benefit-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-dialog[open] {
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.icon-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
}

.icon-close-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.modal-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 14.5px;
}

.text-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.text-input.is-key {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--status-danger-bg);
  border: 1px solid rgba(239, 91, 91, 0.4);
  color: #ffb0b0;
  font-size: 12.5px;
}

.form-error[hidden] {
  display: none;
}

.form-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Lightbox Dialog */
.lightbox-dialog {
  width: min(1040px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-gold);
  background: var(--bg-dialog);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.lightbox-dialog[open] {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 0.85fr);
}

.lightbox-stage {
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 360px;
  max-height: calc(100dvh - 34px);
}

.lightbox-stage img {
  max-width: 100%;
  max-height: calc(100dvh - 68px);
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.lightbox-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  border-inline-start: 1px solid var(--border-subtle);
  overflow-y: auto;
  max-height: calc(100dvh - 34px);
}

.lightbox-prompt {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  word-break: break-word;
}

.action-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.action-group-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.action-buttons-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lightbox-footer-actions {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-danger-ghost {
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid #8c2b3c;
  background: linear-gradient(180deg, #431620 0%, #2e0f17 100%);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 4px 12px rgba(0, 0, 0, 0.22);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.btn-danger-ghost:hover {
  background: linear-gradient(180deg, #5c1c2b 0%, #41121d 100%);
  border-color: #c93b54;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 6px 16px rgba(190, 38, 66, 0.28);
  transform: translateY(-1px);
}

/* Mobile Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 35;
}

.sidebar-backdrop.is-open {
  display: block;
}

/* --- Responsive --- */
@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(270px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .topbar {
    padding: 0 14px;
  }

  .content-wrap {
    padding: 14px 14px 28px;
  }

  .lightbox-dialog[open] {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .lightbox-stage {
    min-height: 200px;
    max-height: 46dvh;
    padding: 12px;
  }

  .lightbox-stage img {
    max-height: calc(46dvh - 24px);
  }

  .lightbox-panel {
    border-inline-start: 0;
    border-top: 1px solid var(--border-subtle);
    max-height: none;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-right {
    gap: 6px;
  }

  .breadcrumbs > span {
    display: none;
  }

  .breadcrumbs strong {
    font-size: 14px;
  }

  #queue-pill {
    display: none;
  }

  .status-pill {
    padding: 6px 11px;
    font-size: 12.5px;
    gap: 6px;
  }
}

@media (max-width: 560px) {
  .topbar {
    height: 56px;
  }

  .mobile-menu-btn,
  .theme-toggle-btn {
    width: 34px;
    height: 34px;
  }

  .status-pill {
    padding: 5px 10px;
    font-size: 12px;
  }

  .content-wrap {
    padding: 12px 12px 24px;
    gap: 16px;
  }

  .composer-form {
    padding: 14px;
    gap: 10px;
  }

  .composer-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .composer-toolbar .composer-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .composer-toolbar .composer-actions .btn-secondary,
  .composer-toolbar .composer-actions .btn-primary {
    width: 100%;
    padding: 10px 12px;
    font-size: 13.5px;
  }

  .gallery-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .gallery-title-wrap {
    width: 100%;
    justify-content: space-between;
    align-items: baseline;
  }

  .gallery-controls {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .search-box {
    grid-column: 1 / -1;
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .filter-select {
    width: 100%;
    min-width: 0;
    height: 38px;
  }

  .density-group {
    height: 38px;
    align-items: center;
  }

  .empty-state {
    min-height: 220px;
    padding: 28px 14px;
  }

  .gallery-grid.density-sm {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .ratio-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .params-popover {
    inset-inline: 12px;
    inset-block-start: 68px;
    width: auto;
    max-height: calc(100dvh - 84px);
  }

  .modal-benefits {
    grid-template-columns: 1fr;
  }
}
