/* AssetForge (web) — the desktop build's dark theme, laid out for a browser
   window rather than a fixed app window: the stage grid collapses to one column
   on a narrow screen, which the Tauri build never has to do. */
:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232c;
  --line: #2a323d;
  --text: #e6edf3;
  --dim: #9aa7b4;
  --faint: #6e7c8c;
  --accent: #f59e0b;
  --accent-dim: #b8770a;
  --good: #3fb950;
  --bad: #f85149;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* Classes below set `display`, which outranks the user-agent rule for the
   `hidden` attribute — so `el.hidden = true` would set the flag and change
   nothing on screen. Every overlay and modal here is toggled that way. */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  height: 54px;
  flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: 0.2px; }
.brand small { color: var(--faint); font-weight: 500; letter-spacing: 1px; text-transform: uppercase; font-size: 10px; }
.mark {
  width: 14px; height: 14px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #ef4444);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}
.steps { display: flex; gap: 4px; margin-left: auto; margin-right: auto; }
.step {
  background: none; border: 1px solid transparent; color: var(--faint);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px;
}
.step b {
  display: inline-block; width: 17px; height: 17px; line-height: 17px; text-align: center;
  border-radius: 50%; background: var(--panel-2); color: var(--dim); font-size: 11px; margin-right: 6px;
}
.step:hover:not(:disabled) { color: var(--text); }
.step.active { color: var(--text); border-color: var(--line); background: var(--panel-2); }
.step.active b { background: var(--accent); color: #1a1206; }
.step.done b { background: var(--good); color: #06210c; }
.step:disabled { opacity: 0.4; cursor: default; }
.topbar-right { display: flex; gap: 8px; }

/* ── buttons & fields ────────────────────────────────────────────────────── */
button { font: inherit; cursor: pointer; border-radius: 8px; }
.ghost {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--dim); padding: 7px 12px;
}
.ghost:hover { color: var(--text); border-color: #3a4552; }
.ghost.small { padding: 4px 9px; font-size: 12px; }
.primary {
  background: var(--accent); border: 1px solid var(--accent); color: #1a1206;
  font-weight: 650; padding: 9px 14px;
}
.primary:hover { background: #ffae1a; }
.primary:disabled, .ghost:disabled { opacity: 0.45; cursor: default; }
.big { width: 100%; padding: 12px; font-size: 15px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; flex: 1; }
.field > span { font-size: 12px; color: var(--dim); }
.field > span small { color: var(--faint); }
select, input, textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%;
}
textarea { resize: vertical; line-height: 1.45; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent-dim); }
.row { display: flex; gap: 10px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; margin-bottom: 12px; }
.check input { width: auto; }
.btnrow { display: flex; gap: 8px; margin-top: 4px; }
.btnrow > button { flex: 1; }
.spacer { flex: 1; }

/* ── stages ──────────────────────────────────────────────────────────────── */
#main { flex: 1; min-height: 0; position: relative; }
.stage { display: none; height: 100%; grid-template-columns: 1fr 340px; gap: 12px; padding: 12px; }
.stage.active { display: grid; }
@media (max-width: 900px) { .stage.active { grid-template-columns: 1fr; grid-template-rows: 1fr auto; overflow: auto; } }

.pane {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 0; overflow: hidden; position: relative;
}
.side { padding: 16px; display: flex; flex-direction: column; overflow-y: auto; }
.side h2 { margin: 0 0 6px; font-size: 15px; }
.hint { color: var(--faint); font-size: 12.5px; margin: 0 0 14px; }
.hint b { color: var(--dim); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; word-break: break-all; }
.err {
  background: rgba(248, 81, 73, 0.12); border: 1px solid rgba(248, 81, 73, 0.4);
  color: #ffb4b0; border-radius: 8px; padding: 9px 11px; font-size: 12.5px; margin-top: 10px;
  white-space: pre-wrap;
}
.provider-note { color: var(--faint); font-size: 12px; margin: -6px 0 12px; }
.provider-note.bad { color: #ffb4b0; }
.provider-note.ok { color: var(--good); }

/* ── chat ────────────────────────────────────────────────────────────────── */
.chat-pane { display: flex; flex-direction: column; }
.transcript { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 78%; padding: 10px 13px; border-radius: 12px; white-space: pre-wrap; font-size: 13.5px; }
.msg.user { align-self: flex-end; background: var(--accent-dim); color: #1a1206; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--faint); font-style: italic; }
.empty-chat { margin: auto; color: var(--faint); text-align: center; max-width: 380px; font-size: 13px; }
.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; }
.composer button {
  background: var(--accent); border: 1px solid var(--accent); color: #1a1206; font-weight: 650; padding: 10px 18px;
}

/* ── image stage ─────────────────────────────────────────────────────────── */
.image-pane, .viewer-pane { display: flex; flex-direction: column; }
.canvas-wrap { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; padding: 16px; min-height: 0; }
#refImage { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow); object-fit: contain; }
.placeholder { color: var(--faint); }
.filmstrip { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); overflow-x: auto; min-height: 62px; }
.filmstrip img { height: 42px; border-radius: 5px; border: 2px solid transparent; cursor: pointer; }
.filmstrip img.sel { border-color: var(--accent); }

/* ── busy overlay ────────────────────────────────────────────────────────── */
.busy {
  position: absolute; inset: 0; background: rgba(14, 17, 22, 0.85); backdrop-filter: blur(3px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 5;
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy-text { font-size: 14px; }
.busy-sub { color: var(--faint); font-size: 12px; }
.bar { width: 220px; height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }

/* ── viewer ──────────────────────────────────────────────────────────────── */
#viewerCanvas { flex: 1; width: 100%; min-height: 0; display: block; }
.viewer-hud {
  display: flex; gap: 6px; align-items: center; padding: 9px 12px; border-top: 1px solid var(--line);
}
.stats { margin-left: auto; color: var(--faint); font-size: 12px; }

/* ── download ────────────────────────────────────────────────────────────── */
.export-pane { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.export-card { width: min(520px, 100%); }
.export-card h2 { margin: 0 0 6px; }
.manifest { list-style: none; padding: 0; margin: 0 0 18px; }
.manifest li {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-size: 13px;
}
.manifest li span:last-child { color: var(--faint); font-size: 12px; }

/* ── modals ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(6, 8, 11, 0.7); z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.sheet {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  width: min(620px, 100%); max-height: 86vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.sheet header h2 { margin: 0; font-size: 15px; }
.sheet-body { padding: 18px; overflow-y: auto; }
.sheet-body h3 { font-size: 13px; color: var(--dim); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: 0.6px; }
.sheet-body h3:first-child { margin-top: 0; }

.prov-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.prov {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.prov .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: 0 0 auto; }
.prov.ready .dot { background: var(--good); }
.prov .who { font-size: 13px; }
.prov .why { color: var(--faint); font-size: 12px; margin-left: auto; text-align: right; }

.keychips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--faint);
}
.chip.on { color: var(--good); border-color: rgba(63, 185, 80, 0.4); }

.runs-list { display: flex; flex-direction: column; gap: 6px; }
.run-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.run-row:hover { border-color: var(--accent-dim); }
.run-row .when { margin-left: auto; color: var(--faint); font-size: 12px; }

/* ── the access gate ──────────────────────────────────────────────────────── */

/* ── the sign-in page ─────────────────────────────────────────────────────────

   Styled to sit in the same family as the platform's other front doors (Atmos's
   login card is the reference): a full-bleed gradient field with slow ambient
   motion behind it, one elevated card that rises into place, a generous logo
   lockup, a single full-width provider button, and the fine print set quietly
   below a hairline.

   What is *not* borrowed is the palette. Atmos is a blue daylight app with a
   white card; AssetForge is orange on graphite — the amber the app's mark, its
   buttons and its progress bars already use, over the same near-black the rest
   of the UI sits on. There is no second hue anywhere on this page: a cool cast
   in the background would read as another product's login wearing our badge.
   Same composition, same weights, same polish, one colour. */
.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  position: relative;
  /* The forge, as depth rather than decoration: the fire low and to the left,
     its heat thinning up and to the right, over graphite. */
  background:
    radial-gradient(78rem 40rem at 10% 114%, rgba(245, 158, 11, 0.20), transparent 62%),
    radial-gradient(52rem 30rem at 86% -14%, rgba(239, 68, 68, 0.10), transparent 64%),
    linear-gradient(168deg, #14161a 0%, var(--bg) 52%, #08090b 100%);
}

/* Ambient drift behind the card — Atmos floats clouds; a forge throws embers.
   Purely decorative, pointer-transparent, and switched off for anyone who has
   asked for less motion. */
.embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.ember {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(245, 158, 11, 0.55), rgba(239, 68, 68, 0.12) 60%, transparent 70%);
  filter: blur(0.4px);
  opacity: 0;
  animation: emberRise 14s ease-in-out infinite;
}
.ember:nth-child(1) { width: 10px; height: 10px; left: 12%; bottom: -6%; animation-delay: 0s;   animation-duration: 15s; }
.ember:nth-child(2) { width: 6px;  height: 6px;  left: 26%; bottom: -8%; animation-delay: 3.5s; animation-duration: 18s; }
.ember:nth-child(3) { width: 14px; height: 14px; left: 68%; bottom: -6%; animation-delay: 6s;   animation-duration: 13s; }
.ember:nth-child(4) { width: 8px;  height: 8px;  left: 82%; bottom: -9%; animation-delay: 1.5s; animation-duration: 20s; }
.ember:nth-child(5) { width: 5px;  height: 5px;  left: 45%; bottom: -5%; animation-delay: 8s;   animation-duration: 16s; }
.ember:nth-child(6) { width: 11px; height: 11px; left: 57%; bottom: -7%; animation-delay: 11s;  animation-duration: 17s; }

@keyframes emberRise {
  0%   { transform: translate3d(0, 0, 0) scale(0.8);        opacity: 0; }
  12%  {                                                    opacity: 0.75; }
  50%  { transform: translate3d(28px, -46vh, 0) scale(1.1); opacity: 0.5; }
  85%  {                                                    opacity: 0.15; }
  100% { transform: translate3d(-14px, -92vh, 0) scale(0.7); opacity: 0; }
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  background: linear-gradient(180deg, rgba(28, 35, 44, 0.96), rgba(22, 27, 34, 0.96));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  backdrop-filter: blur(8px);
  padding: 34px 30px 26px;
  overflow: hidden;
  animation: cardRise 0.55s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

/* One lit filament along the top edge — the card's only ornament, and the same
   amber the app's mark is made of. */
.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), #ef4444, transparent);
  opacity: 0.85;
}

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

.login-card .brand {
  justify-content: center;
  margin-bottom: 18px;
  font-size: 22px;
  letter-spacing: 0.3px;
}
.login-card .brand .mark {
  width: 22px; height: 22px; border-radius: 6px;
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.55);
}
.login-card .brand small { font-size: 11px; }

.login-card .hint {
  margin: 0 0 22px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: var(--dim);
}

.login-card .err { margin-top: 14px; text-align: center; }

/* The footer note, set back behind a hairline the way Atmos sets its own —
   present, quiet, and the place the allowlist rule is stated out loud. */
.login-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--faint);
  font-size: 11.5px;
  line-height: 1.6;
}

.login-fineprint {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  text-align: center;
  color: var(--faint);
  font-size: 11px;
  opacity: 0.75;
}

/* Google's own guidance: their mark, unmodified, on a light button, with the
   wording people already recognise. A sign-in button that looks invented is a
   sign-in button people hesitate over — so this one stays light even in a dark
   card, which is exactly how Atmos treats its Discord button. */
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 13px 20px;
  border-radius: 12px;
  background: #fff;
  color: #1f1f1f;
  font: 600 15px/1 "Roboto", "Inter", system-ui, sans-serif;
  text-decoration: none;
  border: 1px solid #dadce0;
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}
/* Atmos glows its provider button in the provider's colour on hover; ours glows
   in AssetForge's, because the accent on this page is the accent everywhere
   else in the app. Google's mark inside the button is untouched — that part is
   theirs and may not be recoloured. */
.google-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.30);
  transform: translateY(-1px);
}
.google-btn:active { transform: translateY(0); }
.google-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.google-btn.disabled { opacity: 0.45; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .login-card { animation: none; }
  .ember { animation: none; opacity: 0.25; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 20px 22px; border-radius: 14px; }
  .login-card .brand { font-size: 19px; }
}

/* Who is spending the credits, in the top bar. On a shared screen this is the
   difference between "the forge" and "your forge". */
.whoami {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
  color: var(--faint);
  font-size: 12px;
  max-width: 220px;
}
.whoami img { width: 22px; height: 22px; border-radius: 50%; }
.whoami span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
