/* ── Tokens ────────────────────────────────────────────── */
:root {
  --bg:       #060e18;
  --bg-2:     #0d1b2e;
  --panel:    rgba(10, 22, 38, 0.82);
  --panel-hi: rgba(16, 32, 54, 0.88);
  --soft:     rgba(255, 255, 255, 0.05);
  --border:   rgba(255, 255, 255, 0.08);
  --border-hi:rgba(255, 255, 255, 0.14);
  --text:     #f0f6fc;
  --text-2:   rgba(200, 218, 245, 0.72);
  --text-3:   rgba(200, 218, 245, 0.48);
  --accent:   #6ec8ff;
  --accent-2: #5eedb5;
  --accent-3: #a78bfa;
  --glow:     0 0 80px rgba(110, 200, 255, 0.08);
  --shadow:   0 24px 64px rgba(0, 0, 0, 0.4);
  --radius:   20px;
  --radius-sm:14px;
  --radius-xs:10px;
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  /* Safe area env vars for notched devices */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 60% 50% at 15% 10%, rgba(110,200,255,0.12), transparent),
    radial-gradient(ellipse 50% 50% at 85% 80%, rgba(94,237,181,0.08), transparent),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  /* Prevent pull-to-refresh in standalone PWA */
  overscroll-behavior-y: contain;
  /* Disable tap highlight on mobile */
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
/* Prevent text selection on interactive elements in app mode */
button { -webkit-user-select: none; user-select: none; }
ul { list-style: none; }

/* ── Ambient orbs ──────────────────────────────────────── */
.orb {
  position: fixed; border-radius: 50%; pointer-events: none;
  filter: blur(80px); opacity: 0.18; will-change: transform;
}
.orb-a { width: 36rem; height: 36rem; top: -12rem; left: -10rem; background: radial-gradient(circle, rgba(110,200,255,0.8), transparent 70%); }
.orb-b { width: 30rem; height: 30rem; right: -8rem; bottom: -10rem; background: radial-gradient(circle, rgba(94,237,181,0.7), transparent 70%); }

/* ── Shell ─────────────────────────────────────────────── */
.app-shell {
  position: relative; z-index: 1;
  width: min(1120px, 100% - 2rem);
  margin: 0 auto;
  padding: 2rem 0 1.5rem;
  display: grid;
  gap: 1.5rem;
}

/* ── Header ────────────────────────────────────────────── */
.header { padding: 0 0.25rem; }
.logo {
  font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--accent);
}
.tagline {
  margin-top: 0.25rem;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700; line-height: 1.15;
  letter-spacing: -0.03em;
}

/* ── Panel ─────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* ── Workspace ─────────────────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1rem;
  align-items: start;
}

/* ── Mode Switcher ─────────────────────────────────────── */
.mode-switcher { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.mode-tab {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.25s var(--ease);
  font-size: 0.88rem; font-weight: 500;
}
.mode-tab:hover { background: rgba(255,255,255,0.06); color: var(--text); border-color: var(--border-hi); }
.mode-tab.active {
  background: rgba(110,200,255,0.12);
  border-color: rgba(110,200,255,0.3);
  color: var(--accent);
  box-shadow: 0 0 20px rgba(110,200,255,0.06);
}
.mode-icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.mode-label { white-space: nowrap; }

.mode-description {
  margin-top: 1rem;
  font-size: 0.88rem; line-height: 1.5;
  color: var(--text-3);
  min-height: 1.4em;
  transition: opacity 0.2s var(--ease);
}

/* ── Form ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
}

.field {
  display: grid;
  gap: 0.3rem;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}
.field.hidden {
  display: none !important;
}
.field-label {
  font-size: 0.82rem; font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
.field-hint {
  font-size: 0.72rem;
  color: var(--text-3);
  line-height: 1.3;
}

.input-wrap {
  display: flex; align-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 0 0.85rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.input-wrap:focus-within {
  border-color: rgba(110,200,255,0.45);
  box-shadow: 0 0 0 3px rgba(110,200,255,0.08);
}
.input-prefix, .input-suffix {
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-3);
  flex-shrink: 0;
  user-select: none;
}
.input-prefix { margin-right: 0.25rem; }
.input-suffix { margin-left: 0.25rem; }

.field input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.75rem 0;
  outline: none;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  -moz-appearance: textfield;
}
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Results ───────────────────────────────────────────── */
.results {
  display: grid;
  gap: 1.25rem;
  align-content: start;
  position: sticky;
  top: 1.5rem;
}

.result-hero {
  text-align: center;
  padding: 1rem 0 0.5rem;
}
.result-eyebrow {
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.result-value {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.result-subtitle {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-2);
}

/* ── Metrics ───────────────────────────────────────────── */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.metric {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.9rem;
  transition: border-color 0.2s var(--ease);
}
.metric:hover { border-color: var(--border-hi); }
.metric-label {
  font-size: 0.72rem; font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric-value {
  margin-top: 0.35rem;
  font-size: 1.05rem; font-weight: 700;
  color: var(--text);
}
.metric-accent .metric-value { color: var(--accent-2); }

/* ── Insight ───────────────────────────────────────────── */
.insight {
  display: flex; align-items: flex-start; gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem; line-height: 1.55;
  color: var(--text-2);
}
.insight-icon {
  width: 1rem; height: 1rem; flex-shrink: 0;
  margin-top: 0.15rem;
  color: var(--text-3);
}

/* ── Footer ────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 0.5rem 0 0;
  font-size: 0.72rem;
  color: var(--text-3);
}

/* ── Utilities ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Standalone PWA tweaks ─────────────────────────────── */
@media (display-mode: standalone) {
  .header { padding-top: 0.5rem; }
  .footer { padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)); }
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .results { position: static; }
}

@media (max-width: 600px) {
  .app-shell { width: 100%; padding: 1.25rem max(0.75rem, env(safe-area-inset-left)) 1rem; gap: 1rem; }
  .panel { padding: 1.1rem; border-radius: 16px; }
  .tagline { font-size: 1.4rem; }
  .form-grid { grid-template-columns: 1fr; gap: 0.85rem; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .metric { padding: 0.7rem; }
  .metric-value { font-size: 0.95rem; }
  .mode-switcher { gap: 0.35rem; }
  .mode-tab { padding: 0.5rem 0.75rem; font-size: 0.82rem; }
  .mode-icon { width: 0.85rem; height: 0.85rem; }
  .result-value { font-size: 2rem; }
}
