/* css/components.css */

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: var(--accent); color: var(--accent-text);
  font-weight: 500; font-size: 13px; cursor: pointer; line-height: 1;
  white-space: nowrap; position: relative;
  transition: background var(--t-med) var(--ease-out), border-color var(--t-med) var(--ease-out),
    color var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.btn:hover  { background: var(--accent-2); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-grad  { background: var(--grad); }
.btn-full  { width: 100%; padding: 13px 20px; }
.btn-lg    { padding: 14px 24px; font-size: 15px; }
.btn-ghost { background: var(--bg-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-3); border-color: var(--border-2); box-shadow: none; }
.btn-soft  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn-soft:hover { box-shadow: none; filter: brightness(1.2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 13px; font-size: 12px; font-weight: 500; }

/* ===== Icon buttons ===== */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer;
  transition: color var(--t-med) var(--ease-out), background var(--t-med) var(--ease-out),
    border-color var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.icon-btn:hover  { color: var(--text); border-color: var(--accent); background: var(--bg-3); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.icon-btn.ghost  { background: transparent; border-color: transparent; }
.icon-btn.ghost:hover { background: var(--bg-2); }

/* ===== Inputs ===== */
.field-label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-2); margin-bottom: 8px;
}
.input, textarea.input {
  width: 100%; padding: 9px 12px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--r-xs); color: var(--text);
  outline: none; transition: border-color var(--t-fast), background-color var(--t-fast), box-shadow var(--t-fast);
}
.input:hover, textarea.input:hover { border-color: var(--border-2); }
.input:focus, textarea.input:focus {
  border-color: var(--accent); background-color: var(--bg);
  box-shadow: none;
}
.input::placeholder { color: var(--text-3); }
textarea.input {
  resize: vertical; min-height: 110px; line-height: 1.55;
  scrollbar-color: var(--border-2) transparent;
}
textarea.input::-webkit-resizer {
  background-color: transparent;
  background-image: linear-gradient(135deg, transparent 0 46%, var(--text-3) 46% 54%, transparent 54% 100%);
}
textarea.input::-webkit-scrollbar-corner { background: transparent; }

/* ===== Custom Dropdown ===== */
.dropdown { position: relative; user-select: none; z-index: 1; }
.dropdown.open { z-index: 80; }
.dropdown-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-xs); cursor: pointer; color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.dropdown-trigger:hover { border-color: var(--border-2); background: var(--bg-3); }
.dropdown.open .dropdown-trigger { border-color: var(--accent); box-shadow: none; background: var(--bg); }
.dropdown-trigger .dd-val { flex: 1; font-weight: 500; font-size: 13px; text-align: left; }
.dropdown-trigger .dd-chevron {
  width: 16px; height: 16px; color: var(--text-3);
  transition: transform var(--t-med) var(--ease-out);
}
.dropdown.open .dd-chevron { transform: rotate(180deg); color: var(--accent); }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 90;
  background: var(--bg-1); border: 1px solid var(--border-2); border-radius: var(--r-xs);
  box-shadow: var(--shadow); padding: 4px; max-height: 280px; overflow-y: auto;
  opacity: 0; transform: translateY(-4px); transform-origin: top;
  pointer-events: none; transition: opacity var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out);
}
.dropdown.open .dropdown-menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--r-xs); cursor: pointer; color: var(--text-2);
  font-size: 13px;
  transition: background var(--t-fast), color var(--t-fast);
}
.dropdown-item:hover { background: var(--bg-2); color: var(--text); }
.dropdown-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.dropdown-item .check { margin-left: auto; opacity: 0; transition: opacity var(--t-fast); }
.dropdown-item.active .check { opacity: 1; }

/* ===== Pills / Chips ===== */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 12px; border-radius: var(--r-full); background: var(--bg-2);
  border: 1px solid var(--border); color: var(--text-2); cursor: pointer;
  font-size: 12.5px; font-weight: 450; line-height: 1;
  transition: border-color var(--t-med) var(--ease-out), color var(--t-med) var(--ease-out),
    background var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.chip:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.chip:active { transform: translateY(0); }
.chip.active {
  background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 500;
}
.chip-sm  { padding: 7px 12px; font-size: 12px; }
.chip-num { width: 40px; height: 40px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: var(--r-xs); }

/* ===== Segmented control ===== */
.segmented {
  display: inline-flex; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 4px; position: relative;
}
.segmented button {
  background: transparent; border: none; padding: 8px 18px; color: var(--text-2);
  cursor: pointer; font-weight: 600; font-size: 12.5px; border-radius: var(--r-xs);
  position: relative; z-index: 1; transition: color var(--t-med); white-space: nowrap;
}
.segmented button.active { color: var(--accent-text); }
.segmented .seg-thumb {
  position: absolute; top: 4px; bottom: 4px; border-radius: var(--r-xs);
  background: var(--accent);
  transition: left var(--t-med) var(--ease-out), width var(--t-med) var(--ease-out);
  z-index: 0;
}

/* ===== Toggle switch ===== */
.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-full); cursor: pointer; transition: background var(--t-med), border-color var(--t-med);
}
.switch .track::before {
  content: ''; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; background: var(--text-2); border-radius: var(--r-full);
  transition: left var(--t-med) var(--ease-out), background var(--t-med);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::before { left: 21px; background: #fff; }

/* ===== Cards ===== */
.glass-card {
  background: var(--bg-1);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
}
.img-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; cursor: pointer; position: relative;
  transition: border-color var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
  contain: layout style paint;
}
.img-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.img-card:active { transform: translateY(0); box-shadow: none; }
.img-card img  { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.img-card .ic-overlay {
  position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: space-between;
  padding: 10px; background: linear-gradient(to top, rgba(0,0,0,0.65), transparent 55%);
  opacity: 0; transition: opacity var(--t-med);
}
.img-card:hover .ic-overlay { opacity: 1; }
.img-card .ic-overlay .ic-name { font-size: 11px; font-weight: 600; color: #fff; }
.img-card .ic-actions { display: flex; gap: 4px; }
.img-card .ic-actions .icon-btn { width: 28px; height: 28px; background: rgba(0,0,0,0.45); border-color: rgba(255,255,255,0.12); color: #fff; }
.img-card .ic-actions .icon-btn:hover { background: rgba(0,0,0,0.7); }
.img-card .ic-status {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: 1; gap: 10px; color: var(--text-2); font-size: 12px; padding: 16px; text-align: center;
}

/* ===== Selection card ===== */
.lib-sel-card { position: relative; }
.lib-sel-card .sel-check {
  position: absolute; top: 7px; right: 7px; width: 22px; height: 22px;
  border-radius: var(--r-xs); background: rgba(0,0,0,0.5); border: 2px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center; color: transparent;
  transition: all var(--t-fast);
}
.lib-sel-card.selected .sel-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.lib-sel-card.selected { border-color: var(--accent) !important; box-shadow: 0 0 0 2px var(--accent-soft); }
.sel-check svg { width: 12px; height: 12px; stroke-width: 3; }

/* ===== Spinner / progress ===== */
.spinner { width: 28px; height: 28px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: 100%; height: 4px; background: var(--bg-3); border-radius: var(--r-full); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: var(--r-full); transition: width var(--t-med) var(--ease-out); }

/* ===== Small toggles (lang/theme) ===== */
.seg-toggle {
  display: inline-flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 3px; position: relative;
}
.seg-toggle .seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: 0;
  background: var(--accent); border-radius: var(--r-full); pointer-events: none; z-index: 0;
}
.seg-toggle button {
  background: transparent; border: none; padding: 5px 12px; border-radius: var(--r-full);
  cursor: pointer; color: var(--text-2); font-size: 11.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  position: relative; z-index: 1;
  transition: color 180ms var(--ease-out);
}
.seg-toggle button.active { background: transparent; color: var(--accent-text); }

.license-gate { max-width: 460px; margin: 48px auto; display: flex; flex-direction: column; gap: 16px; }
.license-kicker { font-family: var(--font-display); font-size: 28px; letter-spacing: -0.04em; }
.license-gate p, .fresh-license { color: var(--text-2); font-size: 13px; line-height: 1.45; }
.license-redeem, .key-row, .fresh-license { display: flex; gap: 8px; align-items: center; width: min(460px, 100%); }
.license-redeem .input, .key-value { flex: 1; min-width: 0; height: 36px; font-family: var(--font-mono); font-size: 12px; }
.key-row .icon-btn { flex: 0 0 36px; }
.license-create { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.days-input, .note-input { height: 36px; }
.days-input { width: 92px; }
.note-input { width: min(240px, 100%); }
.days-input[hidden] { display: none; }
.license-summary { display: flex; gap: 18px; padding: 14px 18px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 12px; }
.license-summary b { color: var(--text); font-weight: 600; margin-right: 4px; }
.license-filters { padding: 0 18px 14px; }
.license-table { border-top: 1px solid var(--border); overflow-x: auto; }
.license-table-head, .license-table-row {
  display: grid; grid-template-columns: 110px 120px minmax(120px, 1fr) 120px 36px;
  gap: 14px; align-items: center; min-width: 620px; padding: 12px 18px;
}
.license-table-head { color: var(--text-3); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.license-table-row { border-top: 1px solid var(--border); font-size: 13px; }
.license-table-row span:last-child, .license-table-head span:last-child { text-align: right; }
.lic-unused { color: var(--text-3); }
.lic-active { color: var(--success); }
.lic-expired { color: var(--danger); }
.settings-row:has(.license-create) { align-items: start; }
.settings-row-right:has(.license-create) { width: min(680px, 100%); }
@media (max-width: 1100px) {
  .settings-row:has(.license-create) { grid-template-columns: 1fr; }
  .settings-row-right:has(.license-create) { justify-content: stretch; }
  .license-create { justify-content: flex-start; }
}
.settings-row-right .license-redeem,
.settings-row-right .key-row { width: min(460px, 100%); }
@media (max-width: 980px) {
  .settings-row:has(.license-redeem),
  .settings-row:has(.key-row) { grid-template-columns: 1fr; }
  .settings-row:has(.license-redeem) .settings-row-right,
  .settings-row:has(.key-row) .settings-row-right { justify-content: stretch; }
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity var(--t-med);
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 480px; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 24px; box-shadow: var(--shadow);
  transform: translateY(8px); opacity: 0;
  transition: transform var(--t-med) var(--ease-out), opacity var(--t-med);
}
.modal-backdrop.show .modal { transform: translateY(0); opacity: 1; }
.modal-wide { max-width: 820px; }
.modal h3 { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 19px; font-weight: 700; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.toast-stack {
  position: fixed; top: 18px; right: 18px; z-index: 400;
  display: flex; flex-direction: column; gap: 8px;
  width: min(320px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 10px 12px; box-shadow: var(--shadow-sm); font-size: 13px; font-weight: 450;
  line-height: 1.4; color: var(--text);
  pointer-events: auto; cursor: pointer; will-change: transform, opacity;
}
.toast.success { border-color: var(--border); }
.toast.success .icon { color: var(--success); flex-shrink: 0; margin-top: 1px; }
.toast.error { border-color: var(--danger); }
.toast.error .icon { color: var(--danger); flex-shrink: 0; margin-top: 1px; }
.avatar-edit {
  display: flex; align-items: center; gap: 12px;
}
.avatar-preview {
  width: 48px; height: 48px; border-radius: var(--r-xs); overflow: hidden;
  background: var(--bg-3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 16px; flex-shrink: 0;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ban-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.admin-ban-ctrl { display: flex; align-items: center; gap: 6px; }
.admin-ban-ctrl .dropdown { min-width: 118px; width: 118px; }
.admin-ban-ctrl .dropdown-trigger { padding: 7px 10px; font-size: 12px; }
.admin-user-acts { flex-wrap: wrap; justify-content: flex-end; }
.admin-user-row { cursor: pointer; }
.admin-user-row:hover { background: var(--bg-2); }
.admin-inspect { display: flex; flex-direction: column; gap: 12px; }
.admin-inspect-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 4px 0 8px; flex-wrap: wrap;
}
.admin-inspect-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-inspect-name { font-family: var(--font-display); font-size: 22px; letter-spacing: -0.02em; }
.admin-inspect-sub { font-size: 12px; color: var(--text-3); }
.admin-inspect-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.admin-tab {
  background: none; border: none; cursor: pointer;
  padding: 9px 14px 10px; color: var(--text-2); font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.admin-feed { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 24px; }
.admin-gen {
  display: grid; grid-template-columns: 96px 1fr;
  gap: 12px; padding: 12px; background: var(--bg-1);
  border: 1px solid var(--border); border-radius: var(--r-sm);
}
.admin-gen-thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; align-self: start; }
.admin-gen-thumbs img, .admin-ref-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: var(--bg-3); border-radius: 2px; cursor: zoom-in;
}
.admin-gen-thumbs img:only-child { grid-column: 1 / -1; }
.admin-gen-body { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.admin-gen-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.admin-gen-model { font-size: 13px; font-weight: 500; }
.admin-gen-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); }
.admin-gen-prompt {
  font-size: 13px; line-height: 1.5; color: var(--text);
  white-space: pre-wrap; word-break: break-word; max-height: 7.5em; overflow: auto;
}
.admin-gen-params { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-chip {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--text-2); border: 1px solid var(--border); border-radius: var(--r-xs);
  padding: 3px 7px;
}
.admin-chip .k { color: var(--text-3); margin-right: 4px; }
.admin-ref-used { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-ref-used img { width: 36px; height: 36px; object-fit: cover; border-radius: 2px; border: 1px solid var(--border); cursor: zoom-in; }
.admin-ref-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; padding: 12px 0 24px;
}
.admin-ref-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--r-xs); overflow: hidden; }
.admin-ref-card .gcm-name { padding: 6px 8px; display: block; }
@media (max-width: 720px) {
  .admin-gen { grid-template-columns: 1fr; }
  .admin-gen-thumbs { grid-template-columns: repeat(4, 1fr); }
}
.acct-fields { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
.acct-fields .input { width: 100%; }

/* ===== Error msg ===== */
.error-msg {
  display: none; align-items: center; gap: 8px; background: var(--danger-soft);
  color: var(--danger); border: 1px solid var(--danger); padding: 11px 14px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 500; margin-bottom: 14px;
}
.error-msg.show { display: flex; }

/* ===== Settings sections ===== */
.settings-section {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: visible;
  position: relative;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.settings-section:has(.dropdown.open),
.settings-section.is-dropdown-host { z-index: 40; }
.settings-section.is-danger { box-shadow: var(--shadow-sm), inset 3px 0 0 var(--danger); }
.settings-section-head {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.settings-section-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
}
.settings-section-title .icon { color: var(--text-3); width: 15px; height: 15px; }
.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, auto);
  align-items: center;
  padding: 16px 18px;
  gap: 12px 28px;
  position: relative;
  overflow: visible;
}
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.settings-row.has-dropdown { z-index: 3; }
.settings-row:has(.dropdown.open) { z-index: 5; }
.settings-row-label { font-weight: 500; font-size: 13px; color: var(--text); line-height: 1.3; }
.settings-row-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.45; max-width: 42em; }
.settings-row-right {
  min-width: 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end;
  overflow: visible;
  position: relative;
}
.settings-row-right .dropdown { min-width: 220px; width: 220px; }
.settings-wrap { max-width: 980px; }
.acct-fields { display: flex; flex-direction: column; gap: 6px; width: min(320px, 100%); }
.acct-fields .field-label { margin-bottom: 0; }
.field-group { margin-bottom: 14px; }
.avatar-edit { justify-content: flex-end; }
@media (max-width: 640px) {
  .settings-row {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 10px;
  }
  .settings-row-right,
  .avatar-edit { justify-content: flex-start; }
  .settings-row-right .dropdown { width: 100%; min-width: 0; }
}

/* ===== Admin ===== */
.admin-user-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; gap: 12px; }
.admin-user-row + .admin-user-row { border-top: 1px solid var(--border); }
.admin-user-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.admin-user-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.admin-user-name { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.admin-user-sub  { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-acts { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.admin-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-2); display: inline-block; flex-shrink: 0; }
.admin-dot.active { background: var(--success); }
.admin-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: var(--r-xs); letter-spacing: 0.04em; text-transform: uppercase; }
.admin-badge.admin  { background: var(--accent-soft); color: var(--accent); }
.admin-badge.danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.admin-badge.warn   { background: rgba(245,158,11,0.15); color: #f59e0b; }
.admin-log-row { display: flex; align-items: flex-start; justify-content: space-between; padding: 12px 18px; gap: 16px; }
.admin-log-row + .admin-log-row { border-top: 1px solid var(--border); }
.admin-log-left  { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.admin-log-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.admin-log-user   { font-size: 13px; font-weight: 600; }
.admin-log-model  { font-size: 12px; color: var(--text-2); }
.admin-log-prompt { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.admin-log-status { font-size: 12px; font-weight: 600; }
.admin-log-time   { font-size: 11px; color: var(--text-3); }

/* ===== Grid card meta ===== */
.grid-card-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; gap: 8px;
}
.gcm-time { font-size: 11px; color: var(--text-3); }
.gcm-name { font-size: 11px; color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== Library sections ===== */
.lib-section {
  margin-bottom: 28px;
  content-visibility: auto;
  contain-intrinsic-size: auto 240px;
}
.lib-section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.lib-section-name { font-weight: 700; font-size: 14px; }
.lib-section-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); background: transparent; padding: 0; }
.lib-row {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 4px; scroll-snap-type: x mandatory;
  position: relative; min-height: 204px;
}
.lib-row::-webkit-scrollbar { height: 4px; }
.lib-row .img-card, .lib-row .img-card.reveal { width: 160px; min-width: 160px; scroll-snap-align: start; }
.lib-row.is-virtual { display: block; height: 204px; }
.lib-row.is-virtual .img-card {
  position: absolute; top: 0; width: 160px; min-width: 160px;
}
.lib-row .img-card img { background: var(--bg-3); }
.lib-select-bar { display: flex; align-items: center; gap: 8px; padding: 10px 0 14px; flex-wrap: wrap; }
.lsb-count { font-size: 12px; color: var(--text-2); font-weight: 600; margin-right: 4px; }

/* ===== Video badge ===== */
.video-badge {
  position: absolute; bottom: 8px; left: 8px;
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,0.6); color: #fff; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: var(--r-xs);
}

/* ===== Aspect ratio picker ===== */
.aspect-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.aspect-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 72px; padding: 10px 6px; border: 1px solid var(--border); border-radius: var(--r-xs);
  cursor: pointer; transition: border-color var(--t-fast), background-color var(--t-fast);
  background: transparent;
}
.aspect-cell:hover { border-color: var(--text-3); }
.aspect-cell.active { border-color: var(--accent); background: transparent; }
.aspect-frame {
  width: 36px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.aspect-visual {
  display: block; box-sizing: border-box;
  background: transparent; border: 1.5px solid var(--text-3); border-radius: var(--r-xs);
  flex-shrink: 0;
}
.aspect-cell.active .aspect-visual { border-color: var(--accent); background: transparent; }
.aspect-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  color: var(--text-3); letter-spacing: 0.06em; white-space: nowrap;
}
.aspect-cell.active .aspect-label { color: var(--accent); }

/* ===== Stage loading (quiet timer) ===== */
.stage-glow-wrap {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.stage-sheet {
  position: absolute; inset: 9%;
  display: grid; grid-template-columns: 1.2fr 0.8fr; grid-template-rows: 1fr 0.72fr;
  gap: 8px; opacity: 0.9;
}
.stage-sheet i {
  display: block; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: linear-gradient(160deg, #2c241e, #0c0b0a 68%);
  position: relative; overflow: hidden;
}
.stage-sheet i:first-child { grid-row: 1 / 3; }
.stage-sheet i::after {
  content: ''; position: absolute; left: 0; right: 0; height: 28%;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  animation: sheetScan 2.8s var(--ease-smooth) infinite;
}
.stage-glow-pulse { display: none; }
.stage-glow-blob, .stage-glow-orb, .stage-glow-ring-outer, .stage-glow-ring-inner { display: none; }
.stage-glow-content { position: relative; text-align: center; z-index: 1; }
@keyframes sheetScan {
  0% { top: -30%; }
  100% { top: 110%; }
}
@media (prefers-reduced-motion: reduce) {
  .stage-sheet i::after { animation: none; top: 18%; }
}
.stage-glow-timer {
  font-family: var(--font-mono); font-size: 48px; font-weight: 500;
  color: var(--on-void); letter-spacing: 0.14em; line-height: 1;
  margin-bottom: 12px; font-variant-numeric: tabular-nums;
}
.stage-glow-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.stage-glow-label::before {
  content: ''; width: 8px; height: 8px; border-radius: var(--r-xs);
  background: var(--accent);
}
.stage-glow-model {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-3);
  margin-top: 8px; font-weight: 400; letter-spacing: 0.06em;
}

/* ===== Source image picker ===== */
.source-img-picker {
  width: 100%; background: var(--bg-2); border: 1.5px dashed var(--border-2);
  border-radius: var(--r-md); padding: 16px 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: all var(--t-fast);
}
.source-img-picker:hover { border-color: var(--accent); background: var(--accent-soft); }
.source-img-picker.has-image { border-style: solid; border-color: var(--accent); padding: 8px; }
.source-img-picker img { width: 100%; border-radius: var(--r-sm); max-height: 200px; object-fit: cover; display: block; }
.source-img-label { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* ===== Empty state ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 20px; text-align: center; color: var(--text-3);
}
.empty-state .es-icon { width: 56px; height: 56px; opacity: 0.35; }
.empty-state .es-title { font-size: 16px; font-weight: 700; color: var(--text-2); }
.empty-state .es-sub   { font-size: 13px; }

/* ===== Lightbox ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(10,8,6,0.94);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t-med);
}
.lightbox.show { opacity: 1; }
.lb-img {
  max-width: 92vw; max-height: 90vh; border-radius: var(--r-md);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55); object-fit: contain;
}
.lb-close {
  position: absolute; top: 18px; right: 18px; width: 44px; height: 44px;
  border-radius: var(--r-full); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.lb-close:hover { background: rgba(255,255,255,0.2); transform: translateY(-1px); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: var(--r-full);
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out); z-index: 1;
}
.lb-nav:hover { background: rgba(255,255,255,0.2); }
.lb-prev:hover { transform: translateY(-50%) translateX(-2px); }
.lb-next:hover { transform: translateY(-50%) translateX(2px); }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }
.lb-meta {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-xs); padding: 8px 20px;
  font-size: 12px; color: rgba(255,255,255,0.7); white-space: nowrap;
}
.lb-actions { display: flex; gap: 8px; }
.lb-actions a, .lb-actions button {
  width: 36px; height: 36px; border-radius: var(--r-xs);
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--t-fast);
}
.lb-actions a:hover, .lb-actions button:hover { background: rgba(255,255,255,0.22); }

/* ===== Reference zone ===== */
.ref-zone {
  width: 100%; background: var(--bg-2); border: 1px dashed var(--border-2);
  border-radius: var(--r-md); padding: 10px 12px;
  display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px;
  transition: border-color var(--t-fast);
}
.ref-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.ref-thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.ref-thumb  { width: 64px; height: 64px; border-radius: var(--r-sm); overflow: hidden; position: relative; border: 1px solid var(--border); }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ref-thumb .rm {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: var(--r-xs);
  background: rgba(0,0,0,0.65); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--t-fast);
}
.ref-thumb .rm:hover { background: var(--danger); }
.ref-thumb .rm svg { width: 10px; height: 10px; }
.ref-zone-empty { color: var(--text-3); font-size: 12.5px; text-align: center; padding: 6px; }
.ref-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ref-count { margin-left: auto; font-size: 11px; color: var(--text-3); font-weight: 700; }



/* ===== Lightbox (components.js uses lb-backdrop / lb-shell) ===== */
.lb-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(12,10,8,0.94);
  display: flex; flex-direction: column; align-items: stretch;
  opacity: 0; transition: opacity var(--t-med);
}
.lb-backdrop.show { opacity: 1; }

.lb-actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; flex-shrink: 0;
}
.lb-action-btn, .lb-close-btn {
  width: 36px; height: 36px; border-radius: var(--r-xs);
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none;
  transition: background var(--t-fast);
}
.lb-action-btn:hover, .lb-close-btn:hover { background: rgba(255,255,255,0.22); }
.lb-action-btn svg, .lb-close-btn svg { width: 16px; height: 16px; }

.lb-shell {
  flex: 1; display: flex; overflow: hidden; min-height: 0; gap: 0;
}

.lb-img-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; padding: 16px;
}
.lb-img {
  max-width: 100%; max-height: 100%; border-radius: 2px;
  object-fit: contain;
}

.lb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: var(--r-xs);
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--t-fast);
}
.lb-arrow:hover { background: rgba(255,255,255,0.22); }
.lb-arrow svg { width: 18px; height: 18px; }
.lb-arrow-l { left: 14px; }
.lb-arrow-r { right: 14px; }

.lb-counter {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.5); padding: 4px 12px; border-radius: var(--r-xs);
}

.lb-fs-btn {
  position: absolute; bottom: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: var(--r-xs);
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.12);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--t-fast);
}
.lb-fs-btn:hover { background: rgba(255,255,255,0.2); }
.lb-fs-btn svg { width: 14px; height: 14px; }

.lb-info {
  width: 280px; flex-shrink: 0; overflow-y: auto; padding: 12px 16px 24px;
  border-left: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.3);
}
.lb-info-section { margin-bottom: 16px; }
.lb-info-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.lb-prompt-text {
  font-size: 13px; line-height: 1.55; color: rgba(255,255,255,0.85);
  white-space: pre-wrap; word-break: break-word;
}
.lb-params { display: flex; flex-direction: column; gap: 6px; }
.lb-param-row { display: flex; gap: 8px; font-size: 12px; }
.lb-pk { color: rgba(255,255,255,0.4); min-width: 80px; flex-shrink: 0; text-transform: capitalize; }
.lb-pv { color: rgba(255,255,255,0.8); word-break: break-all; }
.lb-copy-btn {
  font-size: 11px; padding: 3px 9px; border-radius: var(--r-xs);
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7); cursor: pointer; display: flex; align-items: center; gap: 5px;
  transition: background var(--t-fast);
}
.lb-copy-btn:hover { background: rgba(255,255,255,0.2); }

@media (max-width: 700px) {
  .lb-info { display: none; }
  .lb-shell { flex-direction: column; }
}

/* ===== Dropzone (ref picker modal) ===== */
.dropzone {
  border: 1.5px dashed var(--border-2); border-radius: var(--r-md);
  padding: 18px; text-align: center; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-3); font-size: 13px; margin-bottom: 14px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ===== Masonry grid ===== */
.masonry {
  columns: 4 140px; gap: 10px; padding: 0;
}
.masonry .img-card { margin-bottom: 10px; break-inside: avoid; }

@media (max-width: 600px) { .masonry { columns: 2 120px; } }


/* ===== Reference picker tabs ===== */
.ref-picker-tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.ref-picker-tab {
  padding: 8px 16px; border: none; background: none; cursor: pointer;
  color: var(--text-2); font-size: 13px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.ref-picker-tab:hover  { color: var(--text-1); }
.ref-picker-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
