:root {
  --bg: #0a0b10;
  --bg-soft: #121420;
  --panel: #151826;
  --panel-soft: #1b1f30;
  --text: #e8ecff;
  --muted: #98a2c3;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --accent: #5af2d6;
  --accent-soft: rgba(90, 242, 214, 0.16);
  --danger: #ff6f89;
  --ok: #35d39f;
  --warn: #f2c95a;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 28px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --glow: 0 0 36px rgba(90, 242, 214, 0.14);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 8% -10%, #21253d 0%, transparent 58%),
    radial-gradient(1000px 620px at 98% 0%, #1b223a 0%, transparent 60%),
    linear-gradient(180deg, #0a0b10 0%, #090a0e 100%);
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: var(--space-5);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.topbar-title {
  margin: 0;
  font-size: clamp(1.35rem, 2.1vw, 2rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.topbar-subtitle {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.status-chip.is-ok {
  border-color: rgba(53, 211, 159, 0.45);
  color: #d9ffee;
  background: rgba(53, 211, 159, 0.14);
}

.status-chip.is-bad {
  border-color: rgba(255, 111, 137, 0.48);
  color: #ffd8df;
  background: rgba(255, 111, 137, 0.12);
}

.tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-5);
}

.tab {
  appearance: none;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.tab:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.tab.is-active {
  border-color: rgba(90, 242, 214, 0.46);
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: var(--glow);
}

.pane {
  display: none;
  animation: pane-fade 160ms ease-out;
}

.pane.is-active {
  display: block;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025));
  padding: var(--space-4);
}

.card-title {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
}

.card-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.18s ease, background 0.18s ease;
}

.btn:hover {
  border-color: var(--line-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  border-color: rgba(90, 242, 214, 0.48);
  background: linear-gradient(180deg, rgba(90, 242, 214, 0.28), rgba(90, 242, 214, 0.12));
  box-shadow: var(--glow);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.02);
}

/* Shared top-right app navigation cluster (Studio/Admin). */
.nav-cluster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
}

.btn.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.012em;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn.btn-nav:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.btn.btn-nav:active {
  transform: translateY(0);
  opacity: 0.95;
}

.btn.btn-nav:focus-visible {
  outline: 2px solid rgba(110, 231, 183, 0.35);
  outline-offset: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge.is-ok {
  border-color: rgba(53, 211, 159, 0.45);
  color: #d9ffee;
}

.badge.is-warn {
  border-color: rgba(242, 201, 90, 0.48);
  color: #fff0cb;
}

.badge.is-bad {
  border-color: rgba(255, 111, 137, 0.48);
  color: #ffd8df;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  z-index: 2000;
  pointer-events: none;
}

.toast {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(12, 14, 22, 0.95);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.84rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(6px);
  animation: toast-in 140ms ease-out forwards;
}

.toast.is-ok {
  border-color: rgba(53, 211, 159, 0.5);
}

.toast.is-warn {
  border-color: rgba(242, 201, 90, 0.5);
}

.toast.is-bad {
  border-color: rgba(255, 111, 137, 0.5);
}

.app-error-boundary {
  margin: 0 0 var(--space-4);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 111, 137, 0.45);
  background: rgba(255, 111, 137, 0.12);
  color: #ffe1e7;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-error-boundary.is-visible {
  display: flex;
}

.shell-footer {
  margin-top: var(--space-6);
  color: var(--muted);
  font-size: 0.78rem;
}

.ui-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 4, 8, 0.68);
  padding: 16px;
}

.ui-modal-backdrop.is-open {
  display: flex;
}

.ui-modal {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(19, 22, 33, 0.98), rgba(14, 16, 24, 0.98));
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  padding: 14px;
}

.ui-modal-title {
  margin: 0;
  font-size: 1.02rem;
}

.ui-modal-copy {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ui-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 14px 14px 92px;
  }

  .topbar {
    margin-bottom: var(--space-4);
  }

  .topbar-subtitle {
    font-size: 0.88rem;
  }

  .tabs {
    margin-bottom: var(--space-4);
  }

  .toast-container {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

@media (max-width: 720px) {
  .nav-cluster {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .btn.btn-nav {
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 13px;
  }
}

@keyframes pane-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
