:root {
  --bg: #050816;
  --bg2: #0b1026;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #eef2ff;
  --muted: #aab4d6;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --success: #30f2a3;
  --gold: #ffd76a;
  --danger: #ff8a99;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: "Inter", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124, 92, 255, 0.14), transparent 35%),
    radial-gradient(circle at bottom right, rgba(34, 211, 238, 0.10), transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  color: var(--text);
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.5;
  pointer-events: none;
}

.orb-1 {
  width: 240px;
  height: 240px;
  background: rgba(124, 92, 255, 0.3);
  top: 5%;
  left: -50px;
}

.orb-2 {
  width: 300px;
  height: 300px;
  background: rgba(34, 211, 238, 0.18);
  right: -100px;
  bottom: 10%;
}

.orb-3 {
  width: 220px;
  height: 220px;
  background: rgba(48, 242, 163, 0.12);
  left: 20%;
  bottom: 18%;
}

.grid-overlay {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.15));
  pointer-events: none;
}

.app-shell {
  width: min(1080px, calc(100% - 24px));
  max-width: 100%;
  margin: 18px auto 22px;
  display: grid;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.hero-card,
.result-card,
.history-card,
.premium-card,
.premium-access-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  border-radius: 22px;
  backdrop-filter: blur(16px);
  max-width: 100%;
  overflow: hidden;
  padding: 18px;
}

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.top-badge {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid rgba(124, 92, 255, 0.45);
  background: rgba(124, 92, 255, 0.12);
  color: #d9d0ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.live-dot-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #bfefff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 12px rgba(48, 242, 163, 0.8);
  animation: pulse 1.8s infinite;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 7vw, 4.3rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
}

h1 span {
  color: var(--accent-2);
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.25);
}

.hero-text {
  color: var(--muted);
  margin: 14px 0 14px;
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 720px;
}

.premium-mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 0 0 14px;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 215, 106, 0.24);
  background: rgba(255, 215, 106, 0.07);
  color: #f7dea0;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.premium-mini-badge:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 215, 106, 0.4);
  background: rgba(255, 215, 106, 0.11);
}

.premium-mini-badge__icon {
  font-size: 0.82rem;
  line-height: 1;
}

.premium-banner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0 0 16px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background:
    linear-gradient(135deg, rgba(124, 92, 255, 0.12), rgba(34, 211, 238, 0.08)),
    rgba(255, 255, 255, 0.04);
}

.premium-banner.is-active {
  border-color: rgba(255, 215, 106, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 215, 106, 0.09), rgba(34, 211, 238, 0.06)),
    rgba(255, 255, 255, 0.04);
}

.premium-banner-copy {
  min-width: 0;
}

.premium-banner-eyebrow {
  color: #b9c7ef;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin-bottom: 7px;
}

.premium-banner.is-active .premium-banner-eyebrow {
  color: #ffe8a6;
}

.premium-banner-title {
  color: #eff4ff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.premium-banner-btn {
  width: 100%;
  color: #08111f;
  background: linear-gradient(135deg, var(--accent-2), #92f7ff 65%);
  border: 0;
  border-radius: 14px;
  padding: 13px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.premium-banner.is-active .premium-banner-btn {
  color: #1f1802;
  background: linear-gradient(135deg, #ffe49a, var(--gold));
}

.prompt-bar {
  margin-bottom: 14px;
  padding: 13px 15px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #dbe7ff;
  font-size: 0.95rem;
  min-height: 52px;
  display: flex;
  align-items: center;
}

.chip-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-width: 124px;
  max-width: 168px;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: #d9e5ff;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.1;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-wrap {
  display: grid;
  gap: 12px;
}

textarea,
.premium-access-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(5, 8, 22, 0.5);
  color: var(--text);
  padding: 15px;
  font: inherit;
  outline: none;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

textarea:focus,
.premium-access-input:focus {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08);
}

textarea::placeholder,
.premium-access-input::placeholder {
  color: #95a2c9;
}

.button-row,
.modal-actions,
.premium-access-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

button,
.download-btn {
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
}

.main-btn {
  color: #08111f;
  background: linear-gradient(135deg, var(--accent-2), #92f7ff 65%);
  box-shadow: 0 10px 28px rgba(34, 211, 238, 0.22);
  flex: 1 1 220px;
  border: 0;
}

.ghost-btn,
.secondary-btn,
.download-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ghost-btn {
  flex: 0 0 auto;
}

.small-btn {
  padding: 11px 14px;
  border-radius: 14px;
}

button:active,
.download-btn:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.72;
  cursor: default;
}

.result-header,
.history-header,
.premium-access-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.result-label,
.premium-label {
  color: #98a7d8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  margin-bottom: 6px;
}

.result-header h2,
.history-header h2,
.premium-card h2,
.modal-card h2,
.premium-access-header h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.premium-access-copy {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.premium-access-form {
  margin-bottom: 10px;
}

.premium-access-btn {
  flex: 0 0 auto;
}

.premium-verified-email {
  color: #cde8ff;
  font-size: 0.92rem;
  line-height: 1.45;
  margin-bottom: 6px;
}

.premium-check-status {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.premium-check-status.is-loading {
  color: #cde8ff;
}

.premium-check-status.is-success {
  color: #b9ffd8;
}

.premium-check-status.is-error {
  color: #ffb5bf;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 98px;
  max-width: 120px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(48, 242, 163, 0.12);
  color: #b8ffe0;
  border: 1px solid rgba(48, 242, 163, 0.28);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.status-pill.is-plus {
  background: rgba(255, 215, 106, 0.10);
  color: #ffe7a1;
  border: 1px solid rgba(255, 215, 106, 0.28);
  box-shadow: none;
}

.status-pill.is-error {
  background: rgba(255, 122, 122, 0.10);
  color: #ffc1c1;
  border: 1px solid rgba(255, 122, 122, 0.26);
}

.status-pill.is-limit {
  background: rgba(255, 215, 106, 0.10);
  color: #ffe7a1;
  border: 1px solid rgba(255, 215, 106, 0.24);
}

.scan-status {
  color: #c4cff0;
  font-size: 0.95rem;
  margin-bottom: 12px;
  min-height: 22px;
  line-height: 1.35;
}

.signal-meter {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.signal-fill {
  height: 100%;
  width: 8%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--success));
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.24);
  transition: width 0.45s ease;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.panel,
.premium-item {
  padding: 16px 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  color: #d8e4ff;
  line-height: 1.2;
}

.panel p,
.premium-card p,
.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.result-card.thinking {
  border-color: rgba(34, 211, 238, 0.18);
  box-shadow:
    0 16px 44px rgba(0, 0, 0, 0.38),
    0 0 24px rgba(34, 211, 238, 0.08);
}

.result-card.thinking .panel {
  animation: panelPulse 1.6s ease-in-out infinite;
}

.result-card.thinking .status-pill {
  animation: pulse 1.5s infinite;
}

.upgrade-inline-btn {
  margin: 0 0 12px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-empty {
  color: var(--muted);
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.history-item {
  width: 100%;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.history-item-title {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
}

.history-item-question {
  margin: 0 0 10px;
  color: #dce6ff;
  line-height: 1.45;
}

.history-item-meta {
  color: #94a5d6;
  font-size: 0.86rem;
  line-height: 1.45;
}

.history-item-open {
  margin-top: 10px;
  color: #bfefff;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.premium-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.premium-item {
  color: #ddecff;
  font-weight: 600;
  text-align: center;
}

.hidden {
  display: none !important;
}

.card-preview-wrap {
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

#signalCardCanvas {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 10px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: #0b1026;
}

.site-footer {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 24px));
  max-width: 100%;
  margin: 0 auto 20px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #8e9dc7;
  font-size: 0.84rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(520px, 100%);
  padding: 22px;
  border-radius: 22px;
  background: rgba(12, 18, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.modal-card h2 {
  margin-bottom: 10px;
}

.modal-card p {
  margin-bottom: 16px;
}

.modal-actions .main-btn,
.modal-actions .ghost-btn {
  flex: 1 1 180px;
}

body.is-premium-user #upgradeSection,
body.is-premium-user #premiumAccessSection {
  display: none !important;
}

@keyframes pulse {
  0% {
    transform: scale(0.94);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.03);
    opacity: 1;
  }
  100% {
    transform: scale(0.94);
    opacity: 0.75;
  }
}

@keyframes panelPulse {
  0% {
    opacity: 0.72;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.72;
  }
}

@media (min-width: 860px) {
  .app-shell {
    margin-top: 34px;
  }

  .hero-card,
  .result-card,
  .history-card,
  .premium-card,
  .premium-access-card {
    padding: 24px;
  }

  .result-grid {
    grid-template-columns: 1fr 1fr;
  }

  .chip-toolbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .premium-banner {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .premium-banner-btn {
    width: auto;
    min-width: 144px;
  }

  .premium-access-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
  }

  .premium-access-btn {
    min-width: 170px;
  }

  .action-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .top-row,
  .result-header,
  .history-header,
  .premium-access-header,
  .site-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .premium-grid {
    grid-template-columns: 1fr;
  }

  .action-row {
    grid-template-columns: 1fr 1fr;
  }

  .action-row .secondary-btn,
  .action-row .download-btn {
    width: 100%;
    min-width: 0;
    text-align: center;
  }

  .action-row #cardBtn {
    grid-column: 1 / -1;
  }

  .status-pill {
    align-self: flex-start;
  }
}