*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  background-image:
    radial-gradient(1100px 520px at 15% -10%, rgba(255, 43, 43, 0.09), transparent 60%),
    radial-gradient(900px 400px at 100% 110%, rgba(255, 43, 43, 0.05), transparent 55%);
  background-attachment: fixed;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

button:disabled { cursor: not-allowed; opacity: 0.42; }

[hidden] { display: none !important; }

h1, h2, h3, h4, p { margin: 0; }

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-dim);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #23262f; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #343845; }

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background:
    radial-gradient(900px 500px at 50% 20%, rgba(255, 43, 43, 0.16), transparent 70%),
    var(--bg);
  transition: opacity 0.4s var(--ease), visibility 0.4s;
}

.boot-screen.is-hidden { opacity: 0; visibility: hidden; }

.boot-mark {
  font-size: clamp(38px, 6vw, 74px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}

.boot-mark span {
  color: var(--red);
  margin-left: 10px;
}

.boot-hint { color: var(--text-dim); font-size: 15px; }

.boot-button {
  margin-top: 10px;
  padding: 18px 44px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #fff;
  background: linear-gradient(180deg, var(--red-bright), var(--red-deep));
  border-radius: var(--radius-m);
  box-shadow: 0 10px 40px var(--red-glow);
  transition: transform 0.15s var(--ease), box-shadow 0.2s;
}

.boot-button:hover { transform: translateY(-1px); box-shadow: 0 14px 50px var(--red-glow); }
.boot-note { color: var(--text-muted); font-size: 12px; max-width: 420px; text-align: center; }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--statusbar-h);
}

.app.is-locked { filter: blur(2px) brightness(0.6); pointer-events: none; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0e0f14, #090a0e);
  position: relative;
  z-index: 30;
}

.brand { display: flex; align-items: baseline; gap: 8px; min-width: 250px; }

.brand-mark {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.brand-dj {
  font-size: 19px;
  font-weight: 900;
  color: var(--red);
  letter-spacing: 0.02em;
  text-shadow: 0 0 18px var(--red-glow);
}

.brand-sub {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

.workspaces { display: flex; gap: 2px; background: #0b0c11; padding: 3px; border-radius: 7px; border: 1px solid var(--line-soft); }

.workspace-tab {
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}

.workspace-tab:hover { color: var(--text); }
.workspace-tab.is-active { color: #fff; background: var(--red); box-shadow: 0 4px 18px var(--red-glow); }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.engine-chip, .api-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0c0d12;
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-dim);
}

.engine-dot, .api-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.02);
}

.engine-chip.is-on { color: var(--text); border-color: rgba(53, 208, 127, 0.35); }
.engine-chip.is-on .engine-dot { background: var(--ok); box-shadow: 0 0 10px rgba(53, 208, 127, 0.8); }
.engine-chip.is-suspended .engine-dot { background: var(--warn); }

.api-chip.is-online { color: var(--text); border-color: rgba(53, 208, 127, 0.3); }
.api-chip.is-online .api-dot { background: var(--ok); }
.api-chip.is-offline .api-dot { background: var(--warn); }

.clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  padding: 0 8px;
  letter-spacing: 0.04em;
}

.ghost-button {
  padding: 8px 13px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b0c10;
  transition: all 0.15s;
}

.ghost-button:hover { color: #fff; border-color: #3a3f4d; background: #12141a; }
.ghost-button.is-danger { color: var(--red); border-color: rgba(255, 43, 43, 0.4); }
.ghost-button.is-primary { color: #fff; background: var(--red); border-color: var(--red); }

/* ---------- footer ---------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  border-top: 1px solid var(--line);
  background: #08090c;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  overflow: hidden;
  white-space: nowrap;
}

.status-item.is-ok { color: var(--ok); }
.status-item.is-warn { color: var(--warn); }
.status-item.is-danger { color: var(--red); }
.status-spacer { flex: 1; }
.status-hint { font-family: var(--font); color: var(--text-muted); opacity: 0.8; }
.status-hint kbd { margin: 0 1px; }

/* ---------- generic controls ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), #0d0e13);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-panel);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 10px;
}

.section-title h2 {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--text-dim);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  background: #0c0d12;
}

.badge.is-red { color: var(--red); border-color: rgba(255, 43, 43, 0.35); background: var(--red-soft); }
.badge.is-ok { color: var(--ok); border-color: rgba(53, 208, 127, 0.3); }
.badge.is-warn { color: var(--warn); border-color: rgba(255, 176, 46, 0.3); }

.text-input, .select-input, .textarea-input {
  width: 100%;
  padding: 10px 12px;
  background: #0a0b0f;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.text-input:focus, .select-input:focus, .textarea-input:focus {
  border-color: rgba(255, 43, 43, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 43, 43, 0.10);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12141a;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover { background: #191c24; border-color: #333845; }
.btn:active { transform: translateY(1px); }
.btn.is-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.is-primary:hover { background: var(--red-bright); }
.btn.is-ghost { background: transparent; }
.btn.is-small { padding: 6px 9px; font-size: 10px; }
.btn.is-danger { color: var(--red); border-color: rgba(255, 43, 43, 0.35); }
.btn.is-block { width: 100%; }

.empty-state {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
}

.empty-state strong { color: var(--text-dim); font-size: 13px; font-weight: 600; }

/* ---------- toast ---------- */
.toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--topbar-h) + 10px);
  align-items: center;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}

.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: #14161d;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.22s var(--ease);
}

.toast.is-ok { border-left-color: var(--ok); }
.toast.is-warn { border-left-color: var(--warn); }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: all 0.2s; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  background: rgba(3, 3, 5, 0.75);
  backdrop-filter: blur(8px);
  padding: 24px;
}

.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #101116;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  padding: 22px;
  animation: modal-in 0.18s var(--ease);
}

.modal.is-wide { width: min(880px, 100%); }

@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } }

.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.modal-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.modal-head p { margin-top: 4px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.modal-close { font-size: 20px; color: var(--text-muted); line-height: 1; padding: 2px 6px; }
.modal-close:hover { color: var(--text); }
.modal-body { display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.field { display: grid; gap: 6px; }
.field label { font-size: 10px; letter-spacing: 0.10em; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.field .hint { font-size: 11px; color: var(--text-muted); line-height: 1.45; }

.form-error { color: var(--red); font-size: 12px; min-height: 14px; }

.hidden { display: none !important; }

.drag-ghost {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  padding: 7px 11px;
  background: #1a1d26;
  border: 1px solid var(--red);
  border-radius: 6px;
  font-size: 11px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%);
}
