:root {
  color-scheme: dark;
  --bg: #080d18;
  --bg-elevated: #0d1424;
  --surface: #101829;
  --surface-2: #162033;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --rose: #e11d48;
  --rose-hover: #f43f5e;
  --rose-soft: rgba(225, 29, 72, 0.16);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  scrollbar-width: thin;
  scrollbar-color: #334155 #080d18;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 45% at 50% -10%, rgba(190, 18, 60, 0.22), transparent 65%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(16, 185, 129, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #475569; background-clip: padding-box; }

@keyframes boot-pulse {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.06); opacity: 1; }
}

.boot-splash {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
}
.boot-emblem {
  width: 84px;
  height: 84px;
  border-radius: 1.5rem;
  background: rgba(16, 24, 41, 0.85);
  border: 1px solid rgba(225, 29, 72, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: boot-pulse 1.8s ease-in-out infinite;
}
.boot-title { color: var(--muted); font-size: 0.95rem; font-weight: 500; }

#blazor-error-ui {
  background: #7f1d1d;
  color: #fecaca;
  bottom: 0;
  left: 0;
  position: fixed;
  width: 100%;
  padding: 0.75rem 1rem;
  display: none;
  z-index: 1000;
}
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 6.25rem;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(8, 13, 24, 0.88);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-wrap { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 0.75rem;
  background: rgba(225, 29, 72, 0.16);
  border: 1px solid rgba(225, 29, 72, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-title {
  font-weight: 700;
  font-size: 0.96rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.desktop-nav { display: none; }

.phase-bar-wrap { padding: 0.85rem 1rem 0 1rem; }
.phase-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  background: rgba(16, 24, 41, 0.72);
  border: 1px solid var(--border);
  border-radius: 0.95rem;
  padding: 0.4rem;
}
.phase-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.5rem;
  border-radius: 0.7rem;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  min-width: 0;
}
.phase-step.active {
  background: rgba(225, 29, 72, 0.18);
  color: #fecdd3;
  border: 1px solid rgba(225, 29, 72, 0.35);
}
.phase-step.done {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.phase-step.locked { opacity: 0.62; }
.phase-num {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}
.phase-step.active .phase-num { background: var(--rose); color: #fff; }
.phase-step.done .phase-num { background: var(--emerald); color: #052e16; }
.phase-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.grid-desktop-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.card {
  background: rgba(16, 24, 41, 0.9);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 1.15rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.card-hero {
  background: linear-gradient(145deg, rgba(159, 18, 57, 0.34), rgba(16, 24, 41, 0.96));
  border-color: rgba(225, 29, 72, 0.36);
  text-align: center;
  padding: 1.65rem 1.25rem;
}

.card-locked {
  text-align: center;
  padding: 2.25rem 1.5rem;
  background: linear-gradient(160deg, rgba(22, 32, 51, 0.92), rgba(10, 15, 28, 0.95));
  border-color: var(--border-strong);
}

.card-title {
  font-size: 0.96rem;
  font-weight: 700;
  margin: 0 0 0.65rem 0;
  display: flex;
  align-items: center;
  gap: 0.48rem;
}
.muted { color: var(--muted); font-size: 0.84rem; line-height: 1.45; }

.pill-row { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.4rem; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.pill-btn { cursor: pointer; min-height: 36px; transition: border-color 0.15s ease, background 0.15s ease; }
.pill-btn:hover { border-color: var(--rose); }
.pill-emerald { background: var(--emerald-soft); border-color: rgba(16, 185, 129, 0.38); color: #6ee7b7; }
.pill-rose { background: var(--rose-soft); border-color: rgba(225, 29, 72, 0.42); color: #fda4af; }
.pill-amber { background: var(--amber-soft); border-color: rgba(245, 158, 11, 0.38); color: #fcd34d; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 0.85rem;
  padding: 0.65rem 1rem;
  min-height: 44px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled {
  background: #1e293b;
  color: #64748b;
  border-color: #293548;
  cursor: not-allowed;
  opacity: 1;
}
.btn-primary { background: var(--rose); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--rose-hover); }
.btn-emerald { background: #059669; color: #fff; }
.btn-emerald:hover:not(:disabled) { background: #10b981; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #1e293b; border-color: #475569; }
.btn-danger { background: rgba(225, 29, 72, 0.14); color: #fda4af; border-color: rgba(225, 29, 72, 0.35); }
.btn-danger:hover:not(:disabled) { background: rgba(225, 29, 72, 0.24); }
.btn-sm { min-height: 40px; padding: 0.45rem 0.78rem; font-size: 0.79rem; border-radius: 0.7rem; }
.btn-block { width: 100%; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  background: #090e1a;
  color: var(--text);
  border: 1px solid #334155;
  border-radius: 0.8rem;
  padding: 0.62rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.22);
}

.field-label { display: block; font-size: 0.77rem; color: var(--muted); margin-bottom: 0.35rem; font-weight: 600; }
.row { display: flex; gap: 0.6rem; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }

.alert-error {
  background: rgba(225, 29, 72, 0.14);
  border: 1px solid rgba(225, 29, 72, 0.42);
  color: #fecdd3;
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.84rem;
  line-height: 1.45;
}
.alert-ok {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #a7f3d0;
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.84rem;
  line-height: 1.45;
}
.alert-warn {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fde68a;
  border-radius: 0.85rem;
  padding: 0.75rem 0.9rem;
  font-size: 0.84rem;
  line-height: 1.45;
}

.list-item {
  background: #0a101e;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.8rem 0.9rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.match-name {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: #fff;
  margin: 0.35rem 0;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
  margin: 0.65rem 0 0.35rem 0;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.3s ease;
}

@keyframes orb-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

.voice-orb {
  margin: 0.5rem auto;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  border: 3px solid #475569;
  background: rgba(30, 41, 59, 0.7);
  color: #fff;
  font-size: 2.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.voice-orb.state-ready {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.14), 0 0 28px rgba(56, 189, 248, 0.35);
}
.voice-orb.state-listening {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.28);
  box-shadow: 0 0 0 10px rgba(16, 185, 129, 0.16), 0 0 34px rgba(16, 185, 129, 0.48);
  animation: orb-pulse 1.2s ease-in-out infinite;
}
.voice-orb.state-speaking {
  border-color: #f43f5e;
  background: rgba(225, 29, 72, 0.28);
  box-shadow: 0 0 0 8px rgba(225, 29, 72, 0.12), 0 0 32px rgba(225, 29, 72, 0.45);
  animation: orb-pulse 1.1s ease-in-out infinite;
}
.voice-orb.state-thinking {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.22);
  box-shadow: 0 0 28px rgba(245, 158, 11, 0.35);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  z-index: 40;
  background: rgba(10, 15, 28, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.45rem 0.4rem max(0.55rem, env(safe-area-inset-bottom));
}
.bottom-nav::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 22px;
  background: linear-gradient(to top, rgba(8, 13, 24, 0.85), transparent);
  pointer-events: none;
}

.nav-btn {
  flex: 1;
  position: relative;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  min-height: 48px;
  padding: 0.35rem 0.25rem;
  border-radius: 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.nav-btn.active { color: #fb7185; background: rgba(225, 29, 72, 0.12); }
.nav-svg { width: 20px; height: 20px; flex-shrink: 0; }
.icon-svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-dot {
  position: absolute;
  top: 6px;
  right: 26%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--amber);
}

/* Chat, Markdown & Product Research Cards */
.chat-box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 52dvh;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.msg {
  max-width: 92%;
  padding: 0.8rem 0.95rem;
  border-radius: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}
.msg-user {
  align-self: flex-end;
  background: var(--rose);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
  white-space: pre-wrap;
}
.msg-assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 0.25rem;
}

.md-content { font-size: 0.87rem; line-height: 1.52; }
.md-content p { margin: 0 0 0.45rem 0; }
.md-content p:last-child { margin-bottom: 0; }
.md-content .md-h { font-weight: 700; color: #fff; margin: 0.5rem 0 0.25rem 0; font-size: 0.9rem; }
.md-content .md-h:first-child { margin-top: 0; }
.md-content ul, .md-content ol { margin: 0.25rem 0 0.45rem 0; padding-left: 1.2rem; }
.md-content li { margin-bottom: 0.25rem; }
.md-content code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 0.35rem;
}

.research-wrap {
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.shop-grid { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
.shop-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: #090e1a;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.6rem;
}
.shop-card:hover { border-color: var(--rose); }
.shop-thumb {
  width: 48px;
  height: 48px;
  border-radius: 0.5rem;
  object-fit: cover;
  background: #1e293b;
  flex-shrink: 0;
}
.reddit-card {
  display: block;
  background: #090e1a;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.55rem 0.7rem;
  text-decoration: none;
  color: inherit;
  font-size: 0.78rem;
}
.reddit-card:hover { border-color: #fb923c; }

.code-box {
  background: #050810;
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 0.65rem 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: #6ee7b7;
  word-break: break-all;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 7, 15, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

@media (max-width: 480px) {
  .btn-sm { min-height: 42px; padding: 0.45rem 0.68rem; }
  .phase-step { font-size: 0.68rem; padding: 0.4rem 0.35rem; gap: 0.3rem; }
}

@media (min-width: 840px) {
  .app-shell {
    max-width: 980px;
    padding-bottom: 2.5rem;
  }
  .top-bar {
    padding: 0.85rem 1.35rem;
    border-radius: 0 0 1rem 1rem;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .phase-bar-wrap { padding: 1rem 1.35rem 0 1.35rem; }
  .main-content { padding: 1rem 1.35rem 1.5rem 1.35rem; }
  .grid-desktop-2 {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .grid-span-2 { grid-column: 1 / -1; }
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(16, 24, 41, 0.85);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: 0.25rem;
  }
  .dnav-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    background: transparent;
    border: none;
    color: var(--muted);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.5rem 0.85rem;
    min-height: 40px;
    border-radius: 0.68rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .dnav-btn:hover { color: var(--text); background: rgba(148, 163, 184, 0.08); }
  .dnav-btn.active {
    background: rgba(225, 29, 72, 0.18);
    color: #fda4af;
  }
  .dnav-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--amber);
  }
  .bottom-nav { display: none; }
  .shop-grid { grid-template-columns: 1fr 1fr; }
  .chat-box { max-height: 58dvh; }
}
