:root {
  --bg: #0c0e12;
  --bg-elev: #141820;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #5eead4;
  --accent-dim: rgba(94, 234, 212, 0.15);
  --accent-2: #a78bfa;
  --danger: #fb7185;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(20, 24, 32, 0.95), rgba(12, 14, 18, 0.85));
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: conic-gradient(from 210deg, var(--accent), var(--accent-2), #38bdf8, var(--accent));
  box-shadow: 0 0 24px rgba(94, 234, 212, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 340px) 1fr;
  min-height: 0;
}

.panel-left {
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 16px;
  overflow-y: auto;
}

.viewport-wrap {
  position: relative;
  min-height: 360px;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, #1a2230 0%, var(--bg) 70%);
}

.viewport-toolbar {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
}

.btn-icon svg {
  display: block;
}

.viewport {
  width: 100%;
  height: 100%;
  min-height: 420px;
  cursor: crosshair;
}

.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sidebar-footer {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.55;
  text-align: center;
}

.sidebar-footer p {
  margin: 0 0 8px;
}

.sidebar-footer p:last-child {
  margin-bottom: 0;
}

.sidebar-bmc {
  margin-bottom: 12px;
}

.sidebar-bmc a {
  display: inline-block;
  line-height: 0;
  border-radius: 4px;
  overflow: hidden;
}

.sidebar-bmc a:hover {
  opacity: 0.9;
  text-decoration: none;
}

.sidebar-bmc img {
  width: 109px;
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

.sidebar-footer a {
  color: var(--accent);
  text-decoration: none;
}

.sidebar-footer a:hover {
  text-decoration: underline;
}

.sidebar-footer .sidebar-bmc a:hover {
  text-decoration: none;
}

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 22px 14px;
  border: 1px dashed rgba(94, 234, 212, 0.35);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.file-drop:hover,
.file-drop:focus-within {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.file-drop-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.file-drop-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.status {
  margin: 10px 0 0;
  font-size: 0.85rem;
}

.status.muted,
.muted {
  color: var(--muted);
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 10px;
}

.field {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 4px 10px;
  margin-bottom: 12px;
  align-items: center;
}

.field > span:first-child {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--muted);
}

.field input[type="range"] {
  grid-column: 1 / 2;
  width: 100%;
  accent-color: var(--accent);
}

.field .value {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  min-width: 3.2rem;
  text-align: right;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.row-tight {
  margin-top: 10px;
}

.btn {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 9px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn:not(:disabled):active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.25), rgba(167, 139, 250, 0.2));
  border-color: rgba(94, 234, 212, 0.45);
  color: #ecfeff;
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.38), rgba(167, 139, 250, 0.28));
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.seg {
  display: flex;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.seg-btn {
  flex: 1;
  padding: 9px 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn.is-active {
  background: var(--accent-dim);
  color: var(--accent);
}

.seg-btn:not(.is-active):hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.hidden {
  display: none !important;
}

kbd {
  font-family: var(--mono);
  font-size: 0.75em;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
}

.toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  max-width: min(90%, 420px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(20, 24, 32, 0.92);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(12, 14, 18, 0.72);
  backdrop-filter: blur(4px);
  z-index: 5;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.modal.hidden {
  display: none;
}

.modal-card {
  position: relative;
  width: min(480px, 100%);
  max-height: min(88vh, 640px);
  overflow-y: auto;
  padding: 22px 24px;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-wide {
  width: min(560px, 100%);
}

.modal-card h2 {
  margin: 0 0 14px;
  font-size: 1.35rem;
}

.welcome-steps {
  margin: 0 0 16px;
  padding-left: 1.2rem;
  color: var(--text);
}

.welcome-steps li {
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.help-body section {
  margin-bottom: 16px;
}

.help-body h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: var(--accent);
}

.help-body p,
.help-body ul {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.help-body ul {
  padding-left: 1.1rem;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .panel-left {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 45vh;
  }

  .viewport {
    min-height: 50vh;
  }
}
