@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

/* =====================================================================
   DESIGN TOKENS — Material You (MD3)
   Tonal palette derived from purple seed (#6750A4).
   ===================================================================== */

:root {
  /* ---- Surfaces (tonal depth hierarchy) ---- */
  --bg-0: #FFFBFE;
  --bg-1: #F3EDF7;
  --bg-2: #E7E0EC;
  --panel: rgba(243, 237, 247, 0.72);
  --panel-strong: rgba(243, 237, 247, 0.92);

  /* ---- Borders & Lines ---- */
  --line: rgba(121, 116, 126, 0.22);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 28px;
  --radius-pill: 9999px;

  /* ---- Text ---- */
  --text: #1C1B1F;
  --text-dim: #49454F;

  /* ---- Brand & Semantic ---- */
  --accent: #6750A4;
  --accent-container: #EADDFF;
  --on-accent-container: #21005D;
  --accent-alt: #7D5260;
  --danger: #B3261E;
  --danger-container: #F9DEDC;
  --ok: #1B6D3D;
  --ok-container: #C4EED0;

  /* ---- Chart palette (RGB channels for alpha flexibility) ---- */
  --chart-blue: 103, 80, 164;
  --chart-teal: 0, 105, 92;
  --chart-teal-alt: 125, 82, 96;
  --chart-orange: 255, 139, 92;
  --chart-orange-alt: 234, 195, 150;
  --chart-purple: 103, 80, 164;
  --chart-label: #1C1B1F;
  --chart-tick: #49454F;
  --chart-grid: 121, 116, 126;

  /* ---- Typography ---- */
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: "Roboto", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* ---- Spacing scale (4px base) ---- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  /* ---- Motion ---- */
  --ease-md: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 200ms;
  --dur-std: 300ms;

  /* ---- Shadows ---- */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 28px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.05);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--sans);
  font-weight: 400;
  color: var(--text);
  background: var(--bg-0);
  min-height: 100vh;
  line-height: 1.55;
}

/* Organic blur shapes for atmosphere */
body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  z-index: 0;
  filter: blur(80px);
}

body::before {
  width: 500px;
  height: 500px;
  top: -120px;
  right: -80px;
  background: rgba(103, 80, 164, 0.10);
}

body::after {
  width: 400px;
  height: 400px;
  bottom: -60px;
  left: -60px;
  background: rgba(125, 82, 96, 0.08);
}

a {
  color: inherit;
}

/* ---- Accessibility: focus-visible ring (MD3 style) ---- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

:focus:not(:focus-visible) {
  outline: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 9999;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
  font-weight: 500;
  text-decoration: none;
}
.skip-link:focus {
  left: 8px;
}

/* =====================================================================
   SHELL & HEADER
   ===================================================================== */

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 22px 56px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
  padding: 12px 20px;
  background: rgba(255, 251, 254, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

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

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  transition: opacity var(--dur-fast) var(--ease-md);
}
.brand-link:active { opacity: 0.8; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.brand-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

/* ---- Navigation (pill-shaped links) ---- */
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  text-decoration: none;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  color: var(--text-dim);
  background: transparent;
  transition: background var(--dur-std) var(--ease-md), color var(--dur-fast) var(--ease-md), box-shadow var(--dur-std) var(--ease-md);
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-link:hover {
  color: var(--accent);
  background: rgba(103, 80, 164, 0.08);
}

.nav-link:active {
  transform: scale(0.95);
}

.nav-link.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* =====================================================================
   LAYOUT
   ===================================================================== */

.page-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}

/* =====================================================================
   PANELS & CARDS — Tonal surfaces, generous radii
   ===================================================================== */

.panel {
  background: var(--panel);
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-std) var(--ease-md);
}

.panel h2,
.panel h3,
.panel h4 {
  margin: 0;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  color: var(--on-accent-container);
  background: var(--accent-container);
  border: none;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
}

.panel-copy {
  color: var(--text-dim);
  margin: 0;
  line-height: 1.55;
  font-size: 0.95rem;
}

.panel-copy + .panel-copy {
  margin-top: 8px;
}

/* =====================================================================
   FORM CONTROLS — MD3 filled text fields
   ===================================================================== */

.input-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 120px auto;
  gap: 10px;
}

.input-grid.compact {
  grid-template-columns: 1.4fr 220px auto;
}

.input-grid-tight {
  grid-template-columns: 220px;
  margin-top: 0;
}

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

.field-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.input,
.select,
.textarea {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--line);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  padding: 14px 14px 12px;
  transition: border-color var(--dur-fast) var(--ease-md), background var(--dur-fast) var(--ease-md);
}

.textarea {
  resize: vertical;
  min-height: 120px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
}

.input::placeholder,
.select::placeholder,
.textarea::placeholder {
  color: rgba(28, 27, 31, 0.38);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  background: rgba(103, 80, 164, 0.05);
  outline: none;
  box-shadow: none;
}

.input:focus:not(:focus-visible),
.select:focus:not(:focus-visible),
.textarea:focus:not(:focus-visible) {
  outline: none;
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.password-field {
  position: relative;
}

.password-field .input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  transition: color var(--dur-fast) var(--ease-md), background var(--dur-fast) var(--ease-md);
}

.password-toggle:hover {
  color: var(--accent);
  background: rgba(103, 80, 164, 0.08);
}

/* =====================================================================
   BUTTONS — Pill-shaped, state layers, tactile feedback
   ===================================================================== */

.button {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 12px 24px;
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  color: var(--accent);
  background: transparent;
  transition: background var(--dur-std) var(--ease-md), box-shadow var(--dur-std) var(--ease-md), transform var(--dur-fast) var(--ease-md);
}

.button:hover {
  background: rgba(103, 80, 164, 0.08);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.button:active {
  transform: scale(0.95);
}

.button.primary {
  border: none;
  background: var(--accent);
  color: #ffffff;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.button.primary:hover {
  background: rgba(103, 80, 164, 0.90);
  box-shadow: var(--shadow-md);
}

.button.primary:active {
  background: rgba(103, 80, 164, 0.80);
  transform: scale(0.95);
}

.button.warn {
  border-color: rgba(179, 38, 30, 0.4);
  color: var(--danger);
}

.button.warn:hover {
  background: rgba(179, 38, 30, 0.06);
}

.button:disabled {
  opacity: 0.50;
  cursor: not-allowed;
  transform: none;
}

/* =====================================================================
   STATUS / FEEDBACK
   ===================================================================== */

.status {
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--text-dim);
  min-height: 1.2em;
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: var(--ok);
}

/* =====================================================================
   KPI GRID
   ===================================================================== */

.kpi-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-grid.kpi-grid-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.kpi {
  background: var(--bg-1);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  transition: box-shadow var(--dur-std) var(--ease-md), transform var(--dur-std) var(--ease-md);
}

.kpi:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.kpi-label {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kpi-value {
  margin: 8px 0 0;
  font-size: 1.3rem;
  font-weight: 700;
}

/* =====================================================================
   INSIGHT GRID / OPTION BUTTONS
   ===================================================================== */

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

.view-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-btn {
  text-align: left;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-1);
  color: var(--text);
  padding: 12px;
  cursor: pointer;
  transition: background var(--dur-std) var(--ease-md), box-shadow var(--dur-std) var(--ease-md), transform var(--dur-fast) var(--ease-md);
}

.option-btn:hover {
  background: rgba(103, 80, 164, 0.08);
  box-shadow: var(--shadow-sm);
}

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

.option-btn.active {
  background: var(--accent-container);
  color: var(--on-accent-container);
  box-shadow: var(--shadow-sm);
}

.option-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 500;
}

.option-copy {
  margin-top: 4px;
  display: block;
  color: var(--text-dim);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* =====================================================================
   COLLAPSIBLE / DETAILS
   ===================================================================== */

.collapsible {
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-1);
  overflow: hidden;
}

.collapsible > summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  list-style: none;
  transition: background var(--dur-fast) var(--ease-md);
}

.collapsible > summary:hover {
  background: rgba(103, 80, 164, 0.05);
}

.collapsible > summary::-webkit-details-marker {
  display: none;
}

.collapsible[open] > summary {
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.collapsible-body {
  padding: 12px 14px 14px;
}

/* =====================================================================
   RESULT STACK / CARDS
   ===================================================================== */

.result-stack {
  display: grid;
  gap: 12px;
}

.card {
  background: var(--bg-1);
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  transition: box-shadow var(--dur-std) var(--ease-md), transform var(--dur-std) var(--ease-md);
}

.card:hover {
  box-shadow: var(--shadow-sm);
}

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

.card-copy {
  color: var(--text-dim);
  margin: 4px 0 0;
  font-size: 0.9rem;
}

.code,
.json {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 220px;
}

/* =====================================================================
   CHARTS & GRAPHS
   ===================================================================== */

.chart-wrap {
  height: 300px;
}

.graph-wrap {
  min-height: 460px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--bg-1);
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.04);
}

.graph-meta {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 0.86rem;
}

/* =====================================================================
   LISTS
   ===================================================================== */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.list-item {
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--bg-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background var(--dur-fast) var(--ease-md), box-shadow var(--dur-std) var(--ease-md);
}

.list-item:hover {
  background: rgba(103, 80, 164, 0.05);
  box-shadow: var(--shadow-sm);
}

.list-item-name {
  font-weight: 500;
}

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

.mono-block {
  margin: 10px 0 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--bg-2);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row .field {
  flex: 1;
  min-width: 220px;
}

/* =====================================================================
   CHECKBOX
   ===================================================================== */

.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.45;
}

.check input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--accent);
}

.check-text {
  display: inline-block;
}

.check-inline {
  align-items: center;
}

.check-inline input[type="checkbox"] {
  margin-top: 0;
}

.check-policy {
  max-width: 100%;
}

/* =====================================================================
   RECOVERY CARD
   ===================================================================== */

.recovery-card {
  margin-top: 12px;
  background: var(--accent-container);
  border: none;
}

.recovery-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.recovery-code {
  margin: 10px 0 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  padding: 12px 14px;
  word-break: break-word;
}

.footer-note {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* =====================================================================
   SITE GATE (password overlay)
   ===================================================================== */

body.site-locked {
  overflow: hidden;
}

.site-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(28, 27, 31, 0.32);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.site-gate.visible {
  display: flex;
}

.site-gate-card {
  width: min(420px, 100%);
  border: none;
  border-radius: var(--radius-xl);
  background: var(--bg-0);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.site-gate-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
}

.site-gate-copy {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.site-gate-form {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

/* =====================================================================
   AUTH (login/register)
   ===================================================================== */

.auth-actions {
  display: flex;
  background: var(--bg-2);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-action-btn {
  flex: 1;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: all var(--dur-std) var(--ease-md);
  text-align: center;
}

.auth-action-btn:hover {
  color: var(--text);
  background: rgba(103, 80, 164, 0.05);
}

.auth-action-btn:active {
  transform: scale(0.95);
}

.auth-action-btn.active {
  color: var(--on-accent-container);
  background: var(--accent-container);
  box-shadow: var(--shadow-sm);
}

.auth-reveal {
  animation: authReveal 0.25s var(--ease-md);
}

@keyframes authReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form .button.primary {
  margin-top: 4px;
}

.auth-link {
  margin-top: 16px;
  font-size: 0.88rem;
  text-align: center;
}

.auth-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-link a:hover {
  text-decoration: underline;
}

.auth-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

/* =====================================================================
   ACCOUNT PAGE
   ===================================================================== */

.account-section {
  margin-top: 20px;
}

.account-section-title {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.danger-zone {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 2px solid rgba(179, 38, 30, 0.20);
}

.danger-summary {
  color: var(--danger);
  font-weight: 500;
}

/* =====================================================================
   HOME PAGE LAYOUT
   ===================================================================== */

.home-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.home-section {
  background: var(--panel);
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-std) var(--ease-md), transform var(--dur-std) var(--ease-md);
}

.home-section:hover {
  box-shadow: var(--shadow-md);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 0;
}

.kpi-grid.kpi-grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

/* Monthly challenge card */
.challenge-card {
  background: var(--accent-container);
  border: none;
}

.challenge-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--on-accent-container);
}

.challenge-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.challenge-member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease-md), transform var(--dur-fast) var(--ease-md);
}

.challenge-member:hover {
  background: rgba(255, 255, 255, 0.85);
  transform: translateX(2px);
}

.challenge-member.completed {
  background: var(--ok-container);
  color: var(--ok);
}

.challenge-member.pending {
  color: var(--text-dim);
}

.challenge-check {
  font-size: 1rem;
  line-height: 1;
}

.challenge-films {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-left: 2px;
}

/* =====================================================================
   UTILITY CLASSES
   ===================================================================== */

.full-width       { grid-column: 1 / -1; }
.mx-auto          { margin-left: auto; margin-right: auto; }
.panel-narrow      { max-width: 480px; }
.panel-medium      { max-width: 620px; }
.panel-wide        { max-width: 780px; }
.panel-xl          { max-width: 900px; }
.panel-2xl         { max-width: 980px; }

.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }

.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }

.m-0    { margin: 0; }

.flex-card         { flex: 1; min-width: 280px; }
.flex-card-lg      { flex: 1; min-width: 320px; }
.flex-card-hero    { flex: 1 1 560px; }
.flex-card-side    { flex: 1 1 320px; }
.flex-fill         { flex: 1; }

.self-end    { align-self: end; }
.items-end   { align-items: end; }
.stretch     { align-items: stretch; }

.btn-block   { width: 100%; }
.inline-block { display: inline-block; }
.no-underline { text-decoration: none; }

.card ol.card-copy { margin: 0; padding-left: 18px; }
.pl-md { padding-left: 18px; }

/* =====================================================================
   RESPONSIVE BREAKPOINTS
   ===================================================================== */

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

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

  .input-grid.compact {
    grid-template-columns: 1fr 1fr;
  }

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

  .kpi-grid.kpi-grid-5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-grid.kpi-grid-6 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px 10px 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
    border-radius: var(--radius-lg);
  }

  .nav-links {
    width: 100%;
  }

  .nav-link {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
  }

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

  .input-grid.compact {
    grid-template-columns: 1fr;
  }

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

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

  .kpi-grid.kpi-grid-5 {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid.kpi-grid-6 {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 260px;
  }

  .graph-wrap {
    min-height: 360px;
  }

  .panel, .home-section {
    padding: 18px;
    border-radius: var(--radius-md);
  }

  .home-layout {
    gap: 16px;
  }
}

/* =====================================================================
   GRAPH VISUALIZATIONS (D3.js force-directed) — dark themed
   ===================================================================== */

.graph-viz-container {
  position: relative;
  width: 100%;
  min-height: 420px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #1C1B1F 0%, #2B2930 40%, #332D41 100%);
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.15);
}

.graph-viz-container .graph-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

.graph-viz-container .graph-svg:active {
  cursor: grabbing;
}

.graph-tooltip {
  position: absolute;
  padding: 10px 14px;
  background: rgba(28, 27, 31, 0.94);
  color: #E6E1E5;
  border: 1px solid rgba(103, 80, 164, 0.35);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
  max-width: 240px;
  backdrop-filter: blur(8px);
}

.graph-tooltip strong {
  color: #fff;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(28, 27, 31, 0.7);
  border-top: 1px solid rgba(103, 80, 164, 0.2);
  backdrop-filter: blur(8px);
}

.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #CAC4D0;
}

.graph-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.graph-legend-line {
  width: 18px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.legend-member { background: #D0BCFF; }
.legend-film   { background: #CAC4D0; }
.legend-high   { background: #73DC9C; }
.legend-mid    { background: #D0BCFF; }
.legend-low    { background: #FFB4AB; }

.graph-legend-hint {
  font-size: 0.68rem;
  color: #938F99;
  margin-left: auto;
}

/* =====================================================================
   AVATAR UPLOAD
   ===================================================================== */

.avatar-upload-area {
  display: flex;
  align-items: center;
  gap: var(--space-md, 1rem);
  margin-top: var(--space-sm, 0.5rem);
}
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border: 3px solid var(--bg-0);
  box-shadow: var(--shadow-md);
}
.avatar-initials {
  color: #fff;
  font-weight: 500;
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.25rem);
}
.avatar-hint {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* =====================================================================
   HERO SECTION
   ===================================================================== */

.hero-section {
  background: var(--accent-container);
  border: none;
  border-radius: 32px;
  padding: 48px 40px 40px;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  top: -80px;
  right: -60px;
  border-radius: 50%;
  background: rgba(103, 80, 164, 0.12);
  filter: blur(60px);
  pointer-events: none;
}

.hero-section::after {
  content: "";
  position: absolute;
  width: 200px;
  height: 200px;
  bottom: -40px;
  left: 10%;
  border-radius: 50%;
  background: rgba(125, 82, 96, 0.10);
  filter: blur(50px);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
}

.hero-headline {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--on-accent-container);
  letter-spacing: -0.01em;
}

.hero-body {
  margin: 16px 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 520px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.hero-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 32px;
  position: relative;
  z-index: 1;
}

.hero-highlight {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  transition: background var(--dur-fast) var(--ease-md), transform var(--dur-fast) var(--ease-md);
}

.hero-highlight:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: translateY(-1px);
}

.hero-highlight-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.hero-highlight-text {
  white-space: nowrap;
}

/* =====================================================================
   HOW IT WORKS
   ===================================================================== */

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

.step-card {
  background: var(--bg-1);
  border: none;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  transition: box-shadow var(--dur-std) var(--ease-md), transform var(--dur-std) var(--ease-md);
}

.step-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.step-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.step-body {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* =====================================================================
   FAQ
   ===================================================================== */

.faq-list {
  display: grid;
  gap: 8px;
}

.faq-item {
  background: var(--bg-1);
  border: none;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--dur-std) var(--ease-md);
}

.faq-item:hover {
  box-shadow: var(--shadow-sm);
}

.faq-item[open] {
  box-shadow: var(--shadow-sm);
}

.faq-question {
  cursor: pointer;
  padding: 16px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background var(--dur-fast) var(--ease-md);
}

.faq-question:hover {
  background: rgba(103, 80, 164, 0.05);
}

.faq-question::after {
  content: "+";
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--accent);
  flex-shrink: 0;
  transition: transform var(--dur-std) var(--ease-md);
}

.faq-item[open] .faq-question::after {
  transform: rotate(45deg);
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-answer {
  padding: 0 20px 18px;
}

.faq-answer p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.faq-answer a {
  color: var(--accent);
  font-weight: 500;
}

/* =====================================================================
   SITE FOOTER
   ===================================================================== */

.site-footer {
  margin-top: 48px;
  padding: 32px 0 16px;
  border-top: 1px solid var(--line);
}

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

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

.footer-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.footer-name {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
}

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

.footer-links a {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: color var(--dur-fast) var(--ease-md);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
  width: 100%;
  text-align: center;
  margin-top: 8px;
}

/* ---- Responsive adjustments for new sections ---- */
@media (max-width: 820px) {
  .hero-section {
    padding: 32px 24px 28px;
    border-radius: var(--radius-lg);
  }

  .hero-headline {
    font-size: 1.6rem;
  }

  .hero-highlights {
    gap: 10px;
  }

  .hero-highlight {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .steps-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .step-card {
    text-align: left;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
  }

  .step-number {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }
}
