/* Asset Forge — dark, legible, no framework. */

:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d212a;
  --surface-3: #262b36;
  --border: #2b313d;
  --border-strong: #3a4252;
  --text: #e8eaf0;
  --muted: #9aa3b3;
  --faint: #6b7385;
  --accent: #ff8a3d;
  --accent-strong: #ff9d5c;
  --accent-ink: #1a0f06;
  --accent-soft: rgba(255, 138, 61, 0.14);
  --ok: #3ecf8e;
  --ok-soft: rgba(62, 207, 142, 0.14);
  --warn: #f5c451;
  --warn-soft: rgba(245, 196, 81, 0.14);
  --bad: #f2685f;
  --bad-soft: rgba(242, 104, 95, 0.14);
  --info: #6aaeff;
  --info-soft: rgba(106, 174, 255, 0.14);
  --discord: #5865f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; word-break: break-all; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 6px; }
.skip-link:focus { top: 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow-end { margin-left: auto; }

/* ------------------------------------------------------------ buttons */

.btn {
  --b-bg: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--b-bg); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.btn:hover { background: #303746; text-decoration: none; border-color: #4a5366; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-sm { min-height: 30px; padding: 3px 10px; font-size: 0.85rem; }
.btn-lg { min-height: 44px; padding: 8px 20px; font-size: 1rem; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #1c0605; }
.btn-danger:hover { background: #ff7c73; border-color: #ff7c73; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }
.btn-danger-text { color: var(--bad); }
.btn-danger-text:hover { color: #ff8b84; }
.btn-discord { background: var(--discord); border-color: var(--discord); color: #fff; }
.btn-discord:hover { background: #6a75ff; border-color: #6a75ff; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--accent-ink) transparent var(--accent-ink) transparent;
  animation: spin 0.8s linear infinite;
}
.btn:not(.btn-primary).busy::after { border-color: var(--text) transparent var(--text) transparent; }

.spinner {
  display: inline-block; width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.spinner.sm { width: 12px; height: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .btn.busy::after { animation-duration: 2.4s; }
  .shimmer { animation: none !important; }
}

/* ---------------------------------------------------------- boot/login */

.boot { min-height: 100vh; display: grid; place-content: center; gap: 12px; grid-auto-flow: column; align-items: center; color: var(--muted); }
.boot-error { text-align: center; display: grid; gap: 10px; justify-items: center; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1000px 500px at 50% -10%, rgba(255, 138, 61, 0.16), transparent 60%), var(--bg); }
.login-card {
  width: min(420px, 100%); text-align: center; display: grid; gap: 14px; justify-items: center;
  padding: 36px 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.8rem; }
.login-msg { color: var(--bad); background: var(--bad-soft); padding: 8px 12px; border-radius: var(--radius-sm); }

.brand-mark {
  display: inline-block; width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M7 13h18l-3 5h-4v6h-4v-6h-4z' fill='%231a0f06'/%3E%3C/svg%3E") center/100% no-repeat;
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.brand-mark.big { width: 64px; height: 64px; border-radius: 16px; }

/* ------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 20px; min-height: 60px;
  background: rgba(14, 16, 20, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-project { font-weight: 500; color: var(--muted); font-size: 0.85rem; padding: 1px 8px; border: 1px solid var(--border); border-radius: 99px; }
.brand-project:empty { display: none; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 550; white-space: nowrap; }
.tabs a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--text); background: var(--surface-3); box-shadow: inset 0 -2px 0 var(--accent); }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me-name { font-weight: 550; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget { display: grid; gap: 4px; min-width: 150px; font-size: 0.82rem; color: var(--muted); }
.budget strong { color: var(--text); }
.budget-bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.budget-bar span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width 0.3s; }
.budget.warn .budget-bar span { background: var(--warn); }
.budget.over .budget-bar span { background: var(--bad); }
.budget.over strong { color: var(--bad); }

.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-3); }
.avatar-initial { display: inline-grid; place-items: center; font-size: 0.75em; font-weight: 700; color: var(--muted); }

.banner { padding: 10px 20px; text-align: center; border-bottom: 1px solid var(--border); }
.banner-warn { background: var(--warn-soft); color: #ffe2a0; }

/* --------------------------------------------------------------- main */

main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 80px; outline: none; }
.view { display: grid; gap: 20px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; justify-content: space-between; }
.section-head > p { flex-basis: 100%; }
.section-head h1 + p { flex-basis: auto; flex: 1; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: grid; gap: 16px; align-content: start; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.load-more { display: flex; justify-content: center; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px; justify-content: center; }

.empty { text-align: center; padding: 40px 16px; display: grid; gap: 8px; justify-items: center; color: var(--text); grid-column: 1 / -1;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-art { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-3)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa3b3' stroke-width='1.6' stroke-linejoin='round'%3E%3Cpath d='M12 3 3 7.5v9L12 21l9-4.5v-9z'/%3E%3Cpath d='m3 7.5 9 4.5 9-4.5M12 12v9'/%3E%3C/svg%3E") center/30px no-repeat; }
.empty .row { justify-content: center; margin-top: 6px; }

/* -------------------------------------------------------------- forms */

.create-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.field { display: grid; gap: 6px; flex: 1; min-width: 0; }
.field-narrow { flex: 0 0 140px; }
.label, legend { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.help { font-size: 0.82rem; color: var(--muted); }
.help.bad { color: var(--bad); }
input[type="text"], input[type="number"], input[type="search"], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid="true"]:not(:placeholder-shown) { border-color: var(--bad); }
select option:disabled { color: var(--faint); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 8px; }
.form-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
#prompt { font-size: 1.05rem; }

.mode-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.mode-card { position: relative; display: grid; gap: 2px; padding: 10px 12px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color 0.12s, background 0.12s; }
.mode-card:hover { border-color: var(--border-strong); }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-label { font-weight: 600; }
.mode-hint { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }
.mode-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* segmented choices and pills */
.seg-opts, .pills-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt, .pills-opt { position: relative; cursor: pointer; }
.seg-opt input, .pills-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt { display: grid; padding: 6px 12px; min-width: 44px; text-align: center; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); }
.seg-label { font-weight: 600; }
.seg-hint { font-size: 0.75rem; color: var(--muted); }
.seg-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.seg-opt:has(input:focus-visible), .pills-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pills { display: flex; align-items: center; gap: 8px; }
.pills legend { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pills-opts { gap: 4px; background: var(--surface); border: 1px solid var(--border); padding: 3px; border-radius: 99px; }
.pills-opt { padding: 4px 12px; border-radius: 99px; color: var(--muted); font-size: 0.88rem; font-weight: 550; }
.pills-opt:hover { color: var(--text); }
.pills-opt:has(input:checked) { background: var(--surface-3); color: var(--text); }
.dialog .pills legend { position: static !important; width: auto; height: auto; clip: auto; }
.dialog .pills { display: grid; }
.dialog .pills-opts { justify-self: start; }

.model-opts { display: grid; gap: 14px; }

details.advanced > summary { cursor: pointer; color: var(--muted); font-weight: 550; width: max-content; padding: 2px 0; }
details.advanced > summary:hover { color: var(--text); }
details.advanced[open] > summary { margin-bottom: 12px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 550; font-size: 0.9rem; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 36px; height: 20px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background 0.15s; flex: none; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch input:checked + .switch-ui { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); background: var(--accent-ink); }
.switch-danger input:checked + .switch-ui { background: var(--bad); border-color: var(--bad); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-ui { opacity: 0.5; }

/* upload */
.drop { display: grid; place-items: center; gap: 10px; text-align: center; padding: 22px 16px; min-height: 160px; cursor: pointer;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); transition: border-color 0.12s, background 0.12s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.upload-form input[type="file"]:focus-visible + .drop { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-preview { max-height: 180px; border-radius: var(--radius-sm); object-fit: contain; background: #fff; }

/* -------------------------------------------------------------- cards */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.job-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.job { padding: 14px; display: grid; gap: 10px; align-content: start; }
.job.st-running, .job.st-queued { border-color: rgba(255, 138, 61, 0.45); }
.job-head { display: flex; align-items: center; gap: 10px; }
.job-head .avatar { width: 24px; height: 24px; }
.job-who { display: grid; line-height: 1.2; min-width: 0; flex: 1; }
.job-user { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta a { color: var(--muted); }
.prompt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.job-body { display: grid; gap: 8px; }
.job-foot { display: flex; align-items: center; gap: 8px; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 8px; margin-top: auto; }
.job-foot .row { gap: 2px; justify-content: flex-end; }
.cost { color: var(--muted); font-size: 0.85rem; }
.job-error { color: #ffb0aa; background: var(--bad-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 0.88rem; overflow-wrap: anywhere; }

.thumbs { display: grid; gap: 6px; grid-template-columns: repeat(2, 1fr); }
.thumbs.n1 { grid-template-columns: 1fr; }
.thumbs.n3 { grid-template-columns: repeat(3, 1fr); }
.thumb { position: relative; margin: 0; border-radius: var(--radius-sm); overflow: hidden; background: #f4f4f4; aspect-ratio: 1; }
.thumb-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb figcaption { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 6px; }
.btn-3d { background: rgba(14, 16, 20, 0.82); border-color: rgba(255, 255, 255, 0.12); backdrop-filter: blur(4px); }
.btn-3d:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.shimmer { background: linear-gradient(100deg, var(--surface-2) 20%, var(--surface-3) 50%, var(--surface-2) 80%); background-size: 300% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.running { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.running .mono { margin-left: auto; }

.model-thumb { position: relative; display: block; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: #f4f4f4; }
.model-thumb img { width: 100%; height: 100%; object-fit: contain; }
.st-queued .model-thumb img, .st-running .model-thumb img { opacity: 0.5; filter: grayscale(0.4); }
.thumb-empty { width: 100%; height: 100%; display: grid; place-items: center; background: var(--surface-2); color: var(--faint); font-weight: 700; font-size: 1.4rem; }
.badge-3d { position: absolute; right: 8px; bottom: 8px; padding: 4px 10px; border-radius: 99px; background: rgba(14, 16, 20, 0.85); color: var(--text); font-size: 0.82rem; font-weight: 600; }
.model-thumb:hover .badge-3d { background: var(--accent); color: var(--accent-ink); }

/* chips & badges */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 0.76rem; font-weight: 650; white-space: nowrap; background: var(--surface-3); color: var(--muted); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-queued, .chip-pending, .chip-uploading { background: var(--info-soft); color: var(--info); }
.chip-running, .chip-started { background: var(--accent-soft); color: var(--accent-strong); }
.chip-running::before { animation: pulse 1.2s ease-in-out infinite; }
.chip-done { background: var(--ok-soft); color: var(--ok); }
.chip-failed, .chip-refused { background: var(--bad-soft); color: var(--bad); }
.chip-cancelled { background: var(--surface-3); color: var(--faint); }
@keyframes pulse { 50% { opacity: 0.3; } }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 650; background: var(--accent-soft); color: var(--accent-strong); white-space: nowrap; }
.badge-muted { background: var(--surface-3); color: var(--muted); }
.badge-pending { background: var(--info-soft); color: var(--info); }
a.badge:hover { text-decoration: none; filter: brightness(1.2); }

/* ------------------------------------------------------------ job view */

.jobview { display: grid; gap: 18px; }
.jv-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.jv-who { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.jv-who .avatar { width: 24px; height: 24px; }
.jv-prompt { font-size: 1.05rem; overflow-wrap: anywhere; }
.jv-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.jv-side { display: grid; gap: 16px; }
.stage { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  background: radial-gradient(circle at 50% 35%, #2a303c, #13161c 70%); min-height: 360px; aspect-ratio: 4 / 3; }
.stage.light { background: radial-gradient(circle at 50% 35%, #ffffff, #cfd4dc 75%); }
.stage-tools { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; }
.stage-tools .btn { background: rgba(14, 16, 20, 0.75); color: var(--text); }
.stage-wait { display: grid; place-items: center; align-content: center; gap: 14px; padding: 20px; }
.stage-wait img { max-height: 60%; max-width: 70%; border-radius: var(--radius-sm); opacity: 0.6; background: #f4f4f4; }
.stage-wait .running { background: rgba(14, 16, 20, 0.8); padding: 10px 14px; border-radius: 99px; }
.stage-dialog { aspect-ratio: 4 / 3; min-height: 300px; }
.mv { width: 100%; height: 100%; display: block; --poster-color: transparent; background: transparent; }
.mv-fallback { display: grid; place-content: center; gap: 6px; text-align: center; color: var(--muted); padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.stats > div { background: var(--surface); padding: 8px 12px; }
.stats dt { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.side-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side-imgs figure { margin: 0; display: grid; gap: 4px; }
.side-imgs img { aspect-ratio: 1; object-fit: contain; width: 100%; background: #f4f4f4; border-radius: var(--radius-sm); }
.side-imgs figcaption { font-size: 0.8rem; color: var(--muted); text-align: center; }
.big-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.job-requests { display: grid; gap: 10px; }
.job-requests:empty { display: none; }

/* ------------------------------------------------------------ requests */

.req-list { display: grid; gap: 10px; }
.req { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.req-main { display: grid; gap: 4px; min-width: 0; }
.req-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.req-text { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.req .muted.small { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; }
.req .avatar { width: 18px; height: 18px; }
.req-side { flex: none; }
.waiting { display: inline-flex; align-items: center; gap: 8px; }

/* -------------------------------------------------------------- assets */

.asset-group { display: grid; gap: 12px; margin-bottom: 12px; }
.group-head { display: flex; align-items: center; gap: 10px; font-size: 1rem; color: var(--muted); }
.group-head .count { font-size: 0.8rem; background: var(--surface-3); border-radius: 99px; padding: 0 8px; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.asset { display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.asset-prev { aspect-ratio: 4 / 3; background: radial-gradient(circle at 50% 35%, #2a303c, #13161c 75%); display: grid; place-items: center; border-bottom: 1px solid var(--border); }
.asset-prev.checker { background: repeating-conic-gradient(#2a2f3a 0 25%, #20242d 0 50%) 0 0 / 16px 16px; }
.asset-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset-prev.audio { aspect-ratio: auto; padding: 28px 12px; background: var(--surface-2); }
.asset-prev.audio audio { width: 100%; }
.asset-prev.noprev { color: var(--faint); align-content: center; gap: 2px; font-family: var(--mono); font-size: 1.2rem; }
.asset-info { padding: 10px 12px 4px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.asset-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; }
.asset-name .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.used summary { cursor: pointer; font-size: 0.85rem; color: var(--info); }
.used ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); max-height: 140px; overflow: auto; }
.used li { overflow-wrap: anywhere; }
.unused { color: var(--warn); }
.asset-actions { padding: 8px 10px 12px; gap: 4px; }
.search { max-width: 320px; }

/* -------------------------------------------------------------- admin */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.kpi-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.kpi-value { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.chart { overflow-x: auto; }
.bars { width: 100%; min-width: 480px; height: auto; display: block; }
.bars .grid { stroke: var(--border); stroke-width: 1; }
.bars .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.bars rect { fill: #c46a30; }
.bars .bar:hover rect { fill: var(--accent-strong); }
.bars .today rect { fill: var(--accent); }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
.tbl tr.sub th { font-weight: 500; padding-top: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.total td { font-weight: 700; border-bottom: 0; }
.tbl tr.blocked td { opacity: 0.7; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.who { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.who .avatar { width: 22px; height: 22px; }
.log-prompt { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ dialogs */

.dialog { padding: 0; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow); }
.dialog-wide { width: min(980px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(5, 6, 9, 0.7); backdrop-filter: blur(2px); }
.dialog-form { display: grid; grid-template-rows: auto 1fr auto; max-height: calc(100vh - 34px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.dialog-head h2 { font-size: 1.1rem; overflow-wrap: anywhere; }
.dialog-x { background: none; border: 0; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 6px; }
.dialog-x:hover { color: var(--text); }
.dialog-body { padding: 16px 20px; display: grid; gap: 14px; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.m3d-head { display: flex; gap: 14px; align-items: center; }
.m3d-thumb { width: 96px; height: 96px; object-fit: contain; background: #f4f4f4; border-radius: var(--radius-sm); flex: none; }
.lightbox { display: grid; gap: 12px; }
.lightbox img { max-height: 70vh; margin: 0 auto; object-fit: contain; background: #f4f4f4; border-radius: var(--radius-sm); }

/* ------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-left: 4px solid var(--info); border-radius: var(--radius-sm); box-shadow: var(--shadow); animation: toast-in 0.18s ease-out; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: 0.2s; }
.toast-error { border-left-color: var(--bad); }
.toast-success { border-left-color: var(--ok); }
.toast-body { flex: 1; display: grid; gap: 2px; font-size: 0.9rem; overflow-wrap: anywhere; }
.toast-x { background: none; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; line-height: 1; padding: 0 4px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* -------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .topbar { flex-wrap: wrap; gap: 8px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; }
  .tabs::-webkit-scrollbar { display: none; }
}
@media (max-width: 900px) {
  .create-grid, .jv-grid { grid-template-columns: 1fr; }
  .stage { aspect-ratio: 1; min-height: 0; }
}
@media (max-width: 600px) {
  body { font-size: 14.5px; }
  main { padding: 16px 12px 64px; }
  .topbar { padding: 8px 12px; }
  .brand-name { display: none; }
  .me { gap: 8px; }
  .me-name { display: none; }
  .budget { min-width: 120px; }
  .panel { padding: 14px; }
  .job-grid { grid-template-columns: 1fr; }
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .req { flex-direction: column; align-items: stretch; }
  .search { max-width: none; flex: 1 1 100%; }
  .mode-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-narrow { flex: 1 1 100%; }
  .kpi-value { font-size: 1.3rem; }
  .toasts { right: 12px; left: 12px; width: auto; }
}
.sent p { overflow-wrap: anywhere; margin-top: 6px; }
.side-imgs figcaption { display: grid; justify-items: center; gap: 2px; }
.asset { grid-template-rows: auto 1fr auto auto; }
.asset-dl { padding: 0 10px; }
.asset-dl .btn { padding-left: 4px; }
.upload-progress { flex: 1; height: 8px; accent-color: var(--accent); }
input[type="file"] { font: inherit; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 550; color: var(--text); background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 12px; margin-right: 10px; cursor: pointer; }
