:root {
  --bg-canvas: #07080d;
  --bg-window: #0f1117;
  --bg-tile: #131620;
  --bg-card: #1a1e2c;
  --border: #23283a;
  --border-hover: #3b425e;
  --text: #f8fafc;
  --muted: #94a3b8;
  --dim: #64748b;

  /* Signature Purple Palette */
  --purple: #8b5cf6;
  --purple-hover: #7c3aed;
  --purple-subtle: #2e1065;
  --purple-pill-fg: #c4b5fd;

  /* Companion & Product Accents */
  --blue: #3b82f6;
  --emerald: #10b981;
  --red: #ef4444;
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: "Segoe UI Variable Display", "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Ambient Backdrop Glow */
.ambient-glow {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(135px);
  pointer-events: none;
  opacity: 0.2;
}

.ambient-purple {
  width: 600px;
  height: 600px;
  top: -160px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--purple);
}

.ambient-deep {
  width: 440px;
  height: 440px;
  bottom: 8%;
  right: 6%;
  background: #4c1d95;
}

/* Top Navigation Bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(11, 13, 20, 0.85);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: contain;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-card);
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.dot-purple { background: var(--purple); box-shadow: 0 0 8px var(--purple); }
.dot-blue { background: var(--blue); box-shadow: 0 0 8px var(--blue); }
.dot-emerald { background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 9px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--purple);
  border-color: var(--purple-hover);
  color: #ffffff;
  box-shadow: 0 6px 22px rgba(139, 92, 246, 0.28);
}

.btn-primary:hover {
  background: var(--purple-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--purple-subtle);
  border-color: var(--purple);
  color: #ffffff;
}

.btn-danger-ghost {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-approve {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.btn-approve:hover {
  background: rgba(16, 185, 129, 0.26);
}

.btn-admin,
.btn-admin-authed {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-tile);
  border: 1px solid var(--border);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-admin:hover,
.btn-admin-authed:hover {
  color: var(--text);
  border-color: var(--purple);
  background: var(--purple-subtle);
}

.admin-avatar {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  object-fit: cover;
}

/* ==========================================================================
   Hero Bento Grid
   ========================================================================== */
.hero-section {
  padding-top: 36px;
  padding-bottom: 24px;
}

.hero-bento {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.bento-tile {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  min-width: 0;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.tile-monument {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 52px 32px;
  background: radial-gradient(circle at 50% 28%, rgba(139, 92, 246, 0.15), rgba(19, 22, 32, 0.96) 72%);
  border-color: rgba(139, 92, 246, 0.28);
}

.monument-icon-wrap {
  position: relative;
  margin-bottom: 20px;
}

.monument-glow {
  position: absolute;
  inset: -14px;
  border-radius: 36px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, rgba(217, 70, 239, 0.18) 45%, transparent 72%);
  filter: blur(18px);
  z-index: 0;
}

.monument-logo {
  position: relative;
  z-index: 1;
  width: 128px;
  height: 128px;
  object-fit: contain;
  display: block;
}

.tile-monument h1 {
  margin: 0 0 12px;
  font-size: clamp(2.1rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.monument-sub {
  max-width: 560px;
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.pillar-card {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pillar-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.pillar-purple:hover { border-color: rgba(139, 92, 246, 0.55); }
.pillar-blue:hover { border-color: rgba(59, 130, 246, 0.55); }
.pillar-emerald:hover { border-color: rgba(16, 185, 129, 0.55); }

.pillar-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pillar-head h3 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.pillar-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
}

.turbine-xs {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 7px;
}

.turbine-sm {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
}

.turbine-md {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 13px;
}

/* ==========================================================================
   3 Core Application Bento Sections
   ========================================================================== */
.app-section {
  padding-top: 20px;
  padding-bottom: 12px;
  scroll-margin-top: 82px;
}

.app-bento-shell {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
}

.shell-purple {
  background: linear-gradient(180deg, rgba(46, 16, 101, 0.24) 0%, var(--bg-tile) 48%);
  border-color: rgba(139, 92, 246, 0.32);
}

.shell-blue {
  background: linear-gradient(180deg, rgba(30, 58, 138, 0.2) 0%, var(--bg-tile) 48%);
  border-color: rgba(59, 130, 246, 0.28);
}

.shell-emerald {
  background: linear-gradient(180deg, rgba(6, 78, 59, 0.2) 0%, var(--bg-tile) 48%);
  border-color: rgba(16, 185, 129, 0.28);
}

.app-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.app-header h2 {
  margin: 0 0 6px;
  font-size: 1.65rem;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.app-lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 760px;
}

.app-subgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.sub-tile {
  background: var(--bg-window);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  min-width: 0;
  overflow-wrap: break-word;
}

.sub-tile-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sub-tile h4 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 700;
}

.sub-tile-head h4 {
  margin: 0;
}

.sub-tile p {
  margin: 0;
  font-size: 0.87rem;
  color: var(--muted);
  line-height: 1.55;
}

/* Footer */
.footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  padding: 26px 0;
  color: var(--dim);
  font-size: 0.84rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.footer-links a,
.footer-link-btn {
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.footer-links a:hover,
.footer-link-btn:hover {
  color: var(--text);
}

/* ==========================================================================
   Modals (Downloads & Admin)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(7, 8, 13, 0.82);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  background: var(--bg-tile);
  border: 1px solid var(--border-hover);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.72);
}

.modal-dialog.modal-lg {
  max-width: 780px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  margin: 0 0 2px;
  font-size: 1.2rem;
}

.modal-subtitle {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.modal-close {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--purple);
}

.modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-window);
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.tab-btn {
  padding: 8px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--purple-subtle);
  color: var(--purple-pill-fg);
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.field {
  margin-bottom: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.req { color: var(--purple-pill-fg); }
.opt { color: var(--dim); font-weight: 400; }

.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-window);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--purple);
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 1.05rem !important;
}

.field-hint {
  margin: 4px 0 16px;
  font-size: 0.8rem;
  color: var(--muted);
}

.status-banner {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.status-banner.success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.status-banner.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* Admin Console */
.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
}

.admin-section {
  background: var(--bg-window);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.admin-section h4 {
  margin: 0 0 12px;
  font-size: 0.96rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-head h4 {
  margin: 0;
}

.count-pill {
  background: var(--purple-subtle);
  color: var(--purple-pill-fg);
  border: 1px solid rgba(139, 92, 246, 0.35);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}

.gen-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 1.4fr auto;
  gap: 10px;
  align-items: end;
}

.gen-grid .field {
  margin-bottom: 0;
}

.generated-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.gen-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--purple-pill-fg);
  margin-left: 8px;
}

.gen-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-card);
}

.gen-actions {
  display: flex;
  gap: 8px;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.admin-row-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.85rem;
  min-width: 0;
  overflow-wrap: break-word;
}

.admin-row-sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-row-actions {
  display: flex;
  gap: 8px;
}

.empty-state {
  color: var(--dim);
  font-size: 0.85rem;
  padding: 8px 0;
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .pillar-grid,
  .app-subgrid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
  }
  .app-bento-shell,
  .tile-monument {
    padding: 24px 20px;
  }
  .field-row,
  .gen-grid {
    grid-template-columns: 1fr;
  }
}
