:root {
  /* BM360 × DecAi design tokens — refined dark glass, iOS-native feel */
  --bg-deep: #07080c;
  --bg-elevated: #0e1016;
  --bg-card: rgba(18, 20, 28, 0.72);
  --bg-card-solid: #12141c;
  --bg-glass: rgba(22, 24, 34, 0.55);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f5f7;
  --text-secondary: #a1a7b5;
  --text-muted: #6b7280;
  --accent: #7c9cff;
  --accent-soft: rgba(124, 156, 255, 0.15);
  --accent-glow: rgba(124, 156, 255, 0.35);
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.25);
  --blur: 24px;
  --font: "SF Pro Display", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

body {
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(124, 156, 255, 0.12), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(167, 139, 250, 0.06), transparent 50%),
    radial-gradient(ellipse 60% 40% at 0% 80%, rgba(52, 211, 153, 0.04), transparent 45%);
  background-attachment: fixed;
}

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

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

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 16px 28px;
  padding-top: calc(12px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px 18px;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  background: linear-gradient(to bottom, rgba(7, 8, 12, 0.92), rgba(7, 8, 12, 0.7) 70%, transparent);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c9cff 0%, #a78bfa 50%, #34d399 100%);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.03em;
  color: #0a0b10;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-tag {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill {
  font-size: 11px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(124, 156, 255, 0.25);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 16px;
  flex: 1;
  align-items: start;
}

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

.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}

.card-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  font-weight: 550;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: rgba(10, 11, 16, 0.65);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  min-height: 44px;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(124, 156, 255, 0.5);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 650;
  font-size: 14px;
  letter-spacing: -0.01em;
  transition: transform 0.12s, opacity 0.15s, box-shadow 0.15s;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #7c9cff, #9b8afb);
  color: #0a0b10;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 28px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.stage {
  position: relative;
  min-height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, rgba(48, 56, 72, 0.5), transparent 55%),
    linear-gradient(180deg, #0c0e14 0%, #08090e 100%);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.stage-empty {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-secondary);
  max-width: 320px;
}

.stage-empty .icon {
  font-size: 42px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.stage-empty strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

.progress-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 0 auto 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spec-block h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 650;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.plan-json {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: #c5cbd6;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.full-span {
  grid-column: 1 / -1;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

.alert-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fecaca;
}

.alert-info {
  background: var(--accent-soft);
  border: 1px solid rgba(124, 156, 255, 0.25);
  color: #c7d4ff;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 16px calc(10px + var(--safe-bottom));
  background: rgba(10, 11, 16, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 50;
  justify-content: space-around;
  gap: 4px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 550;
  min-width: 64px;
}

.nav-item.active {
  color: var(--accent);
}

@media (max-width: 900px) {
  .bottom-nav {
    display: flex;
  }
  .app-shell {
    padding-bottom: calc(72px + var(--safe-bottom));
  }
  .stage {
    min-height: 300px;
  }
}

.hidden { display: none !important; }
.col { display: flex; flex-direction: column; gap: 16px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12px; }
.auth-panel { max-width: 420px; margin-bottom: 16px; }
.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.project-btn {
  width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border); color: var(--text);
}
.project-btn.active { background: rgba(124,156,255,0.12); border-color: rgba(124,156,255,0.35); }
.project-btn .pt { font-weight: 600; font-size: 13px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.stage img { width: 100%; height: auto; object-fit: contain; display: block; }
