:root {
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background-color: #020617;
  --primary: #6d5dfc;
  --primary-dark: #4b3fe0;
  --ghost: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.06);
  --text-muted: rgba(255, 255, 255, 0.65);
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(109, 93, 252, 0.35), transparent 60%), #020617;
  color: #fff;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px clamp(16px, 4vw, 48px) 48px;
}

.app-header,
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 20px 28px;
  backdrop-filter: blur(18px);
}

.logo {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.logo span {
  color: var(--primary);
}

.env-state {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  background: rgba(148, 163, 184, 0.25);
}

.pill.live {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

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

button {
  font-family: inherit;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: inherit;
}

button.primary {
  background: var(--primary);
  color: white;
}

button.primary:hover {
  background: var(--primary-dark);
}

button.ghost {
  background: var(--ghost);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.16);
}

button.small {
  padding: 6px 12px;
  font-size: 0.82rem;
}

button.active {
  background: rgba(109, 93, 252, 0.35);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.status-grid article {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 20px;
  backdrop-filter: blur(14px);
}

.label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.6);
}

.value {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 6px 0;
}

.trend {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.trend.positive {
  color: #34d399;
}

.todo {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: rgba(255, 255, 255, 0.85);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 320px;
  gap: 20px;
}

.panel {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(18px);
}

.block-search input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 23, 42, 0.6);
  border-radius: 999px;
  padding: 10px 14px;
  color: white;
}

.block-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 6px;
}

.block-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.block-card:hover {
  transform: translateX(4px);
  border-color: rgba(255, 255, 255, 0.25);
}

.canvas {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.canvas-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.canvas-body {
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 32px;
  min-height: 420px;
  background: rgba(2, 6, 23, 0.3);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.canvas.mobile .canvas-body {
  max-width: 420px;
  margin: 0 auto;
}

.canvas-empty {
  text-align: center;
  padding: 60px 24px;
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  background: rgba(15, 23, 42, 0.4);
}

.block-instance {
  border-radius: 16px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
}

.block-instance .block-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
}

.block-instance button {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.block-instance h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.block-instance p {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
}

.story-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.story-visual {
  flex: 0 0 160px;
}

.story-layout img {
  width: 160px;
  height: 120px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.product-card {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.product-card strong {
  display: block;
  margin-bottom: 6px;
}

.metrics {
  display: grid;
  gap: 10px;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 10px 14px;
}

.metric small {
  color: #34d399;
}

blockquote {
  font-size: 1.2rem;
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.9);
}

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

.event-info {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.block-instance .cta {
  display: inline-flex;
  margin-top: 16px;
  padding: 10px 18px;
  border-radius: 999px;
  background: white;
  color: #0f172a;
  font-weight: 600;
}

.data-panel {
  gap: 16px;
}

.insight-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.insight-card strong {
  font-size: 1.2rem;
}

.timeline ul,
.timeline li,
#eventStream {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline h3 {
  margin: 12px 0 10px;
}

.timeline li {
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.timeline span.time {
  color: var(--text-muted);
}

.analytics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.chart-tile {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.legend {
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.dot.blue {
  background: #60a5fa;
}

.dot.green {
  background: #34d399;
}

.funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.funnel-step {
  display: flex;
  align-items: center;
  gap: 12px;
}

.funnel-bar {
  flex: 1;
  height: 18px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.funnel-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6d5dfc, #34d399);
}

.funnel-step strong {
  width: 120px;
}

.spark {
  margin-top: 16px;
  min-height: 140px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}

.spark svg {
  width: 100%;
  height: 140px;
}

.devices {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.device-row .meter {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  margin: 0 12px;
  position: relative;
}

.device-row .meter span {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  border-radius: inherit;
}

.app-footer {
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(0, 0, 0, 0.78);
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 24px 16px 48px;
  }

  .app-header,
  .app-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
