@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500&display=swap');

:root {
  --purple: #a259ff;
  --purple-light: #c490ff;
  --purple-dark: #6a1fd1;
  --purple-dim: rgba(162, 89, 255, 0.15);
  --purple-border: rgba(162, 89, 255, 0.35);
  --bg-deep: #000000;
  --bg-mid: #0d001a;
  --bg-card: rgba(10, 0, 25, 0.75);
  --text: #f0e8ff;
  --sub: rgba(196, 144, 255, 0.6);
  --glow: 0 0 20px rgba(162, 89, 255, 0.3);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  background: #0d001a;
  min-height: 100%;
  width: 100%;
}

body {
  display: flex;
  background: transparent;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ── Canvas layers (from website) ── */
#star-canvas,
#nebula-canvas,
#bubble-canvas,
#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#star-canvas { z-index: 0; }
#nebula-canvas { z-index: 1; }
#bubble-canvas { z-index: 2; }
#fx-canvas { z-index: 3; }

/* ── Sidebar ── */
.sidebar {
  position: relative;
  z-index: 10;
  width: 230px;
  height: 100vh;
  background: rgba(255, 255, 255, 0);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex-shrink: 0;
}

.sidebar::before {
  display: none;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.08);
}

.logo {
  display: flex;
  justify-content: center;
  padding: 10px 0 16px;
  border-bottom: 1px solid var(--purple-border);
}

.logo img {
  width: 150px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(162,89,255,0.5));
}

/* ── Nav ── */
.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav button {
  width: 100%;
  padding: 10px 14px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sub);
  text-align: left;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.22s ease;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--purple-light);
}

.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 0 16px rgba(162,89,255,0.2);
  backdrop-filter: blur(10px);
}

/* ── Main content ── */
.main {
  position: relative;
  z-index: 10;
  flex: 1;
  padding: 32px 28px;
  overflow-y: auto;
  height: 100vh;
  background: transparent;
}

.section {
  display: none;
  animation: fadeUp 0.4s cubic-bezier(.22,1,.36,1) both;
}

.section.active {
  display: block;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--purple-light);
  text-shadow: 0 0 16px rgba(162,89,255,0.5);
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--purple-border);
}

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--purple-border);
  border-radius: 6px;
  padding: 20px;
  backdrop-filter: blur(16px);
  transition: border-color 0.22s, box-shadow 0.22s;
}

.card:hover {
  border-color: rgba(162,89,255,0.7);
  box-shadow: 0 0 28px rgba(162,89,255,0.15);
}

.card h3 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sub);
  margin-bottom: 14px;
}

.card p {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 20px rgba(162,89,255,0.5);
  margin-bottom: 12px;
}

/* ── Toggle pills ── */
.toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.toggle {
  padding: 5px 12px;
  border-radius: 2px;
  border: 1px solid var(--purple-border);
  background: transparent;
  color: var(--sub);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle:hover {
  background: var(--purple-dim);
  color: var(--purple-light);
}

.toggle.active {
  border-color: rgba(162,89,255,0.8);
  background: var(--purple-dim);
  color: #fff;
  box-shadow: 0 0 10px rgba(162,89,255,0.2);
}

/* ── Graph ── */
.graph-box {
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.274);
  border: 1px solid var(--purple-border);
  border-radius: 4px;
  padding: 10px;
}

canvas {
  width: 100%;
  height: 80px;
  display: block;
}

/* ── History panel ── */
.history, .console {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--purple-border);
  border-radius: 6px;
  padding: 16px;
  height: 360px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.7;
  backdrop-filter: blur(12px);
}

.history::-webkit-scrollbar,
.console::-webkit-scrollbar {
  width: 4px;
}
.console::-webkit-scrollbar-track {
  background: transparent;
}
.console::-webkit-scrollbar-thumb {
  background: rgba(162,89,255,0.4);
  border-radius: 2px;
}

/* ── History list ── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-date-sep {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(162, 89, 255, 0.5);
  padding: 18px 0 8px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: rgba(10, 0, 25, 0.5);
  backdrop-filter: blur(12px);
  transition: all 0.18s ease;
  cursor: pointer;
}

.history-row:hover {
  background: rgba(162, 89, 255, 0.08);
  border-color: rgba(162, 89, 255, 0.25);
}

.site-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-url {
  font-size: 0.72rem;
  color: var(--sub);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.history-cost {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: #f85149;
}

.history-time {
  font-size: 0.68rem;
  color: var(--sub);
}

.history-footer {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.load-more {
  padding: 9px 28px;
  border-radius: 4px;
  border: 1px solid var(--purple-border);
  background: transparent;
  color: var(--sub);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.load-more:hover {
  background: var(--purple-dim);
  border-color: var(--purple);
  color: #fff;
}

.load-more:disabled {
  opacity: 0.35;
  cursor: default;
}

.log {
  margin-bottom: 4px;
  color: rgba(196,144,255,0.7);
}

.time {
  color: rgba(162,89,255,0.5);
  margin-right: 6px;
}

.ok {
  color: #7ee787;
}

.err {
  color: #f85149;
}

/* ── Select ── */
select {
  width: 100%;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 4px;
  border: 1px solid var(--purple-border);
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a259ff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus {
  outline: none;
  border-color: rgba(162,89,255,0.8);
  box-shadow: 0 0 12px rgba(162,89,255,0.2);
}

select option {
  background: #0d001a;
}