/* ==========================================================================
   MOSS Studio — dark control-plane UI
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #070b14;
  --bg-2: #0b1220;
  --panel: rgba(17, 26, 43, 0.82);
  --panel-solid: #111a2b;
  --panel-hi: #16213a;
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.3);
  --text: #e6edf7;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --accent-3: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.9);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over layout rules such as
   `.lightbox { display: flex }`. Without this, hidden overlays keep
   intercepting pointer events and both login and app views render. */
[hidden] { display: none !important; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 620px at 12% -10%, rgba(56, 189, 248, 0.16), transparent 60%),
    radial-gradient(900px 600px at 92% 4%, rgba(167, 139, 250, 0.14), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(52, 211, 153, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

h1, h2, h3, p, dl, dd, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre { font-family: var(--mono); }
a { color: var(--accent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.22); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.36); background-clip: content-box; }

/* ---------------------------------- Login --------------------------------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.55;
}
.orb-a { width: 520px; height: 520px; background: rgba(56, 189, 248, 0.3); top: -160px; left: -120px; }
.orb-b { width: 460px; height: 460px; background: rgba(167, 139, 250, 0.3); bottom: -160px; right: -100px; }

.login-card {
  position: relative;
  width: min(430px, 100%);
  padding: 36px 32px 28px;
  background: linear-gradient(160deg, rgba(22, 33, 58, 0.96), rgba(11, 18, 32, 0.96));
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 1.3rem; letter-spacing: -0.02em; }
.brand p { color: var(--text-dim); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }

.brand-mark {
  width: 42px; height: 42px;
  border-radius: 13px;
  background:
    radial-gradient(circle at 50% 50%, var(--accent-2) 0 14%, transparent 15%),
    radial-gradient(circle at 50% 50%, transparent 0 34%, var(--accent) 35% 42%, transparent 43%);
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 22px -4px rgba(56, 189, 248, 0.6), inset 0 0 18px -6px rgba(56, 189, 248, 0.8);
  flex: none;
}
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; }

.login-lede { color: var(--text-dim); font-size: 0.9rem; margin: 22px 0 24px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .btn { margin-top: 22px; }
.login-foot { margin-top: 18px; text-align: center; font-size: 0.72rem; color: var(--text-faint); letter-spacing: 0.04em; }

/* --------------------------------- Fields --------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex; align-items: baseline; gap: 8px;
}
.field > span em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-faint); font-size: 0.72rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%;
  background: rgba(7, 11, 20, 0.7);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}
textarea { resize: vertical; min-height: 64px; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.14);
  background: rgba(7, 11, 20, 0.95);
}
input::placeholder, textarea::placeholder { color: #4b5a70; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 30px;
}
.select.compact, .input.compact { padding: 7px 10px; font-size: 0.82rem; }
.select.compact { padding-right: 28px; }
.input.compact { width: 220px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.form-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fca5a5;
  font-size: 0.84rem;
}

/* --------------------------------- Buttons -------------------------------- */
.btn {
  --btn-bg: rgba(148, 163, 184, 0.1);
  --btn-line: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--btn-line);
  background: var(--btn-bg);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; border-radius: 8px; }
.btn-lg { padding: 13px 20px; font-size: 0.95rem; }
.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 26px -14px rgba(56, 189, 248, 0.9);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 30px -12px rgba(99, 102, 241, 0.85); }
.btn-danger { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); background: rgba(148, 163, 184, 0.08); }

/* ---------------------------------- App ----------------------------------- */
.app-view { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px;
  background: rgba(7, 11, 20, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex: none; }
.topbar-title { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-title strong { font-size: 0.98rem; letter-spacing: -0.01em; }
.topbar-sub { font-size: 0.68rem; color: var(--text-faint); letter-spacing: 0.09em; text-transform: uppercase; }

.tabs { display: flex; gap: 4px; flex: 1; justify-content: center; }
.tab {
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim);
  padding: 7px 15px; border-radius: 9px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); background: rgba(148, 163, 184, 0.07); }
.tab.is-active { color: var(--text); background: rgba(56, 189, 248, 0.12); border-color: rgba(56, 189, 248, 0.35); }

.topbar-right { display: flex; align-items: center; gap: 12px; flex: none; }
.icon-link { font-size: 0.78rem; color: var(--text-dim); text-decoration: none; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); }
.icon-link:hover { color: var(--text); border-color: var(--line-strong); }

.phase-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 13px; border-radius: 99px;
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.03em;
  border: 1px solid var(--line-strong);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-dim);
}
.phase-pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.phase-pill[data-phase="ready"] { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.1); }
.phase-pill[data-phase="starting"], .phase-pill[data-phase="queued"], .phase-pill[data-phase="booting"] { color: #fcd34d; border-color: rgba(251, 191, 36, 0.4); background: rgba(251, 191, 36, 0.1); }
.phase-pill[data-phase="error"], .phase-pill[data-phase="agent_error"] { color: #fca5a5; border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.1); }
.phase-pill[data-phase="stopping"], .phase-pill[data-phase="stopped"] { color: #cbd5e1; }
.phase-pill[data-phase="starting"] i, .phase-pill[data-phase="booting"] i, .phase-pill[data-phase="stopping"] i { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.main { flex: 1; width: min(1520px, 100%); margin: 0 auto; padding: 24px; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade 0.25s ease both; }
/* Grid/flex children default to min-width:auto, which lets a long <pre> line
   stretch the whole page. Allow every panel column to shrink. */
.studio-grid > *, .rail > *, .api-grid > *, .logs-grid > *, .batch-grid > * { min-width: 0; }
.code-block, .log-output, .manifest { max-width: 100%; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------- Cards --------------------------------- */
.card {
  background: linear-gradient(165deg, rgba(22, 33, 58, 0.72), rgba(11, 18, 32, 0.85));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 20px 50px -34px rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.count { font-size: 0.72rem; color: var(--text-faint); font-weight: 500; }

.hint { color: var(--text-faint); font-size: 0.78rem; }
.hint code { background: rgba(148, 163, 184, 0.14); padding: 1px 6px; border-radius: 5px; color: #cbd5e1; font-size: 0.76rem; }

.empty, .empty-small {
  color: var(--text-faint);
  font-size: 0.86rem;
  text-align: center;
  padding: 42px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}
.empty-small { padding: 22px 14px; font-size: 0.8rem; }

/* -------------------------------- Studio ---------------------------------- */
.studio-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.85fr); gap: 20px; align-items: start; }
.form-card { display: flex; flex-direction: column; gap: 14px; }
.form-card .card-head { margin-bottom: 2px; }

.segment { display: inline-flex; gap: 4px; padding: 4px; background: rgba(7, 11, 20, 0.7); border: 1px solid var(--line-strong); border-radius: 10px; width: fit-content; }
.seg {
  background: transparent; border: none; color: var(--text-dim);
  padding: 6px 14px; border-radius: 7px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.seg.is-active { background: rgba(56, 189, 248, 0.18); color: #bae6fd; }

.res-block { display: flex; flex-direction: column; gap: 10px; }
#size-hint { margin-top: -2px; }

.advanced { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 14px; background: rgba(7, 11, 20, 0.35); }
.advanced summary { cursor: pointer; padding: 12px 0; font-size: 0.82rem; font-weight: 600; color: var(--text-dim); list-style: none; display: flex; align-items: center; gap: 8px; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "▸"; color: var(--accent); transition: transform 0.15s; }
.advanced[open] summary::before { transform: rotate(90deg); }
.advanced-body { display: flex; flex-direction: column; gap: 12px; padding: 4px 0 16px; }

.rail { display: flex; flex-direction: column; gap: 20px; }

.cluster-card .cluster-message { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 14px; }
.cluster-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); }
.dot[data-state="on"] { background: var(--accent-3); box-shadow: 0 0 10px var(--accent-3); }
.dot[data-state="busy"] { background: var(--warn); box-shadow: 0 0 10px var(--warn); animation: pulse 1.3s infinite; }
.dot[data-state="error"] { background: var(--danger); box-shadow: 0 0 10px var(--danger); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.stat-grid.wide { grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.stat-grid dt { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 3px; }
.stat-grid dd { font-size: 0.85rem; font-weight: 600; color: var(--text); word-break: break-word; }

.gpu-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.gpu {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 11, 20, 0.5);
}
.gpu-top { display: flex; justify-content: space-between; gap: 10px; font-size: 0.76rem; margin-bottom: 7px; }
.gpu-name { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gpu-mem { color: var(--text-faint); font-family: var(--mono); font-size: 0.7rem; flex: none; }
.gpu-foot { display: flex; justify-content: space-between; margin-top: 6px; }
.gpu-util { color: var(--accent); font-family: var(--mono); font-size: 0.68rem; }
.meter { height: 5px; border-radius: 99px; background: rgba(148, 163, 184, 0.16); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-3), var(--accent)); transition: width 0.4s ease; }

.chip { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px; background: rgba(148, 163, 184, 0.14); color: var(--text-dim); }
.chip[data-state="running"] { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.chip[data-state="completed"] { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }
.chip[data-state="failed"] { background: rgba(248, 113, 113, 0.16); color: #fca5a5; }

.progress { height: 8px; border-radius: 99px; background: rgba(148, 163, 184, 0.16); overflow: hidden; margin-bottom: 8px; }
.progress span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #0ea5e9, #a78bfa); transition: width 0.35s ease; }

.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.result-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; background: #0a1020; }

.latest-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.latest-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; display: block; background: #0a1020; transition: transform 0.15s, border-color 0.15s; }
.latest-grid img:hover { transform: scale(1.03); border-color: rgba(56, 189, 248, 0.5); }
.latest-grid .empty-small { grid-column: 1 / -1; }

/* --------------------------------- Gallery -------------------------------- */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0a1020;
  transition: border-color 0.15s, transform 0.15s;
}
.tile:hover { border-color: rgba(56, 189, 248, 0.45); transform: translateY(-2px); }
.tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }
.tile-body { padding: 9px 11px 11px; }
.tile-prompt { font-size: 0.76rem; color: var(--text-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 0.66rem; color: var(--text-faint); font-family: var(--mono); }
.tile-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; }
.tile:hover .tile-actions { opacity: 1; }
.tile-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 7px; border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(7, 11, 20, 0.78); color: #e2e8f0; cursor: pointer;
  font-size: 0.8rem; text-decoration: none; backdrop-filter: blur(6px);
}
.tile-btn:hover { background: rgba(56, 189, 248, 0.24); }
.tile-btn.danger:hover { background: rgba(248, 113, 113, 0.3); }

/* --------------------------------- Queue ---------------------------------- */
.queue-list { display: flex; flex-direction: column; gap: 10px; }
.job-row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: rgba(7, 11, 20, 0.45);
}
.job-row-top { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; flex-wrap: wrap; }
.job-id { font-family: var(--mono); font-size: 0.72rem; color: var(--accent); }
.job-prompt { font-size: 0.8rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 900px; }
.job-side { text-align: right; font-size: 0.72rem; color: var(--text-faint); font-family: var(--mono); }

/* ---------------------------------- Logs ---------------------------------- */
.logs-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.log-output {
  margin: 0;
  max-height: 66vh;
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #05080f;
  border: 1px solid var(--line);
  font-size: 0.74rem;
  line-height: 1.65;
  color: #a5b4c8;
  white-space: pre-wrap;
  word-break: break-word;
}
.event-list { display: flex; flex-direction: column; gap: 7px; max-height: 66vh; overflow: auto; }
.event {
  display: grid; grid-template-columns: 62px 1fr; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: rgba(7, 11, 20, 0.45);
  border-left: 2px solid var(--line-strong);
  font-size: 0.76rem;
}
.event[data-level="warn"] { border-left-color: var(--warn); }
.event[data-level="error"] { border-left-color: var(--danger); }
.event time { color: var(--text-faint); font-family: var(--mono); font-size: 0.68rem; }
.event span { color: var(--text-dim); word-break: break-word; }

/* ----------------------------------- API ---------------------------------- */
.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.code-block { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-top: 12px; background: #05080f; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 12px; background: rgba(148, 163, 184, 0.07); border-bottom: 1px solid var(--line); font-size: 0.72rem; color: var(--text-dim); font-family: var(--mono); }
.copy-btn { background: transparent; border: 1px solid var(--line-strong); color: var(--text-dim); padding: 3px 9px; border-radius: 6px; font-size: 0.68rem; cursor: pointer; }
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.code-block pre { margin: 0; padding: 13px 14px; overflow-x: auto; font-size: 0.74rem; line-height: 1.6; color: #b9c7db; }

.endpoint-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.endpoint-list li { display: grid; grid-template-columns: 48px auto 1fr; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px; background: rgba(7, 11, 20, 0.45); font-size: 0.76rem; }
.endpoint-list code { color: #cbd5e1; font-size: 0.74rem; overflow-wrap: anywhere; }
.endpoint-list em { font-style: normal; color: var(--text-faint); text-align: right; overflow-wrap: anywhere; }
.method { font-family: var(--mono); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.05em; padding: 2px 0; text-align: center; border-radius: 4px; }
.method.get { color: #6ee7b7; background: rgba(52, 211, 153, 0.12); }
.method.post { color: #93c5fd; background: rgba(59, 130, 246, 0.14); }

/* -------------------------------- Lightbox -------------------------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 40px;
  background: rgba(3, 6, 12, 0.9);
  backdrop-filter: blur(10px);
}
.lightbox figure { max-width: min(1200px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.lightbox img { max-width: 100%; max-height: 78vh; border-radius: 12px; border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.lightbox figcaption { color: var(--text-dim); font-size: 0.82rem; text-align: center; max-width: 800px; }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: rgba(15, 23, 42, 0.9);
  color: var(--text); font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { border-color: var(--accent); color: var(--accent); }

/* --------------------------------- Toast ---------------------------------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 120;
  padding: 11px 20px; border-radius: 11px;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 0.84rem; color: var(--text);
  max-width: min(560px, calc(100% - 32px));
}
.toast[data-kind="error"] { border-color: rgba(248, 113, 113, 0.5); color: #fca5a5; }
.toast[data-kind="ok"] { border-color: rgba(52, 211, 153, 0.5); color: #a7f3d0; }

/* -------------------------------- Batches --------------------------------- */
.batch-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; align-items: start; }
.manifest {
  min-height: 340px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre;
  resize: vertical;
}
.compact-out { margin-top: 12px; max-height: 220px; }
.batch-list { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow: auto; }
.batch-row {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px;
  background: rgba(7, 11, 20, 0.45);
}
.batch-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.batch-bar { height: 6px; border-radius: 999px; background: rgba(148, 163, 184, 0.16); overflow: hidden; }
.batch-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #38bdf8, #818cf8); }
.batch-items { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.batch-item { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; font-size: 0.72rem; color: var(--text-dim); align-items: center; }
.batch-item code { color: var(--accent); }
.batch-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------------------------- Lightbox details ----------------------------- */
.lightbox-details {
  width: min(760px, 100%);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(7, 11, 20, 0.82);
  font-size: 0.76rem;
  color: var(--text-dim);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 18px;
}
.lightbox-details .ld-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lightbox-details .ld-k { color: var(--text-faint); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; }
.lightbox-details .ld-v { color: var(--text); word-break: break-word; }

/* -------------------------------- Responsive ------------------------------ */
@media (max-width: 1180px) {
  .studio-grid { grid-template-columns: 1fr; }
  .api-grid, .logs-grid, .batch-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
  .tabs { order: 3; flex: 1 0 100%; width: 100%; min-width: 0; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .topbar-right { margin-left: auto; }
  .main { padding: 16px; }
  .row-3 { grid-template-columns: 1fr 1fr; }
  .stat-grid.wide { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .tile-actions { opacity: 1; }
}
@media (max-width: 520px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .latest-grid { grid-template-columns: 1fr 1fr; }
  .cluster-actions { grid-template-columns: 1fr; }
  .input.compact { width: 100%; }
  .main { padding: 12px; }
  .card { padding: 15px; }
  .endpoint-list li { grid-template-columns: 46px minmax(0, 1fr); }
  .endpoint-list em { grid-column: 2; text-align: left; }
  .code-head { flex-wrap: wrap; }
  .lightbox-details { grid-template-columns: 1fr; }
}
