@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0a0e1a;
  --surface: #131826;
  --surface-2: #1a2032;
  --border: #232a3d;
  --border-soft: #1c2235;
  --text: #f5f7fa;
  --text-dim: #8b95ab;
  --text-mute: #5c6580;
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-glow: rgba(34, 211, 238, 0.35);
  --good: #10b981;
  --bad: #f43f5e;
  --warn: #f59e0b;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  letter-spacing: -0.011em;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}

/* ============ SCREENS ============ */
.screen {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px 120px 20px;
  scroll-behavior: smooth;
}
.screen.active {
  display: block;
  animation: screenIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ ONBOARDING ============ */
.onboard {
  display: none;
  padding: 48px 28px;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  justify-content: center;
}
.onboard.active {
  display: flex;
  animation: screenIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.onboard .brand { text-align: center; margin-bottom: 48px; }
.onboard .brand h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #f5f7fa 0%, #8b95ab 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.onboard .brand .sub {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 12px;
  line-height: 1.55;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}
.onboard h2 {
  font-size: 17px;
  margin-bottom: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 40px; }
.chip {
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.chip.selected {
  background: var(--accent);
  color: #0a0e1a;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 24px var(--accent-glow);
}
.chip:active { transform: scale(0.96); }

/* ============ BUTTONS ============ */
.onboard-btn, .btn {
  width: 100%;
  padding: 16px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #0a0e1a;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
  box-shadow: 0 4px 24px var(--accent-glow);
}
.onboard-btn:disabled { opacity: 0.35; box-shadow: none; cursor: not-allowed; }
.onboard-btn:active:not(:disabled), .btn:active { transform: scale(0.98); }
.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn.danger { background: var(--surface); color: var(--bad); border: 1px solid var(--border); box-shadow: none; }

/* ============ HEADER ============ */
.header {
  padding: 24px 0 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.header h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.035em;
}
.header .greet {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.header .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 14px;
  transition: all 0.2s ease;
}
.card-title {
  font-size: 11.5px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  font-weight: 600;
}

/* ============ SNAPSHOT ============ */
.snapshot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.snapshot-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.snapshot-item .label {
  font-size: 10.5px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.snapshot-item .value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 8px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.snapshot-item .value.accent { color: var(--accent); }
.snapshot-item .value.good { color: var(--good); }
.snapshot-item .value.bad { color: var(--bad); }

/* ============ FORM ============ */
label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
input, select {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  margin-bottom: 16px;
  font-family: inherit;
  transition: all 0.18s ease;
  letter-spacing: -0.01em;
}
input::placeholder { color: var(--text-mute); font-weight: 400; }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============ RESULT ============ */
.result {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  display: none;
}
.result.show {
  display: block;
  animation: screenIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.result.yes { border-left-color: var(--good); }
.result.no { border-left-color: var(--bad); }
.result h2 {
  font-size: 20px;
  margin-bottom: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.result p { font-size: 14px; color: #b8c0d1; line-height: 1.6; }
.result b { color: var(--text); font-weight: 600; }
.big {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ============ EMPTY STATE ============ */
.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-mute);
  font-size: 13px;
  line-height: 1.6;
}
.empty .empty-ico {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--text-mute);
  opacity: 0.55;
}

/* ============ BOTTOM NAV ============ */
.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(10, 14, 26, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-soft);
  display: none;
  padding: 8px 4px calc(10px + env(safe-area-inset-bottom));
  z-index: 100;
}
.nav.active { display: flex; }
.nav-item {
  flex: 1;
  text-align: center;
  padding: 8px 4px 6px;
  color: var(--text-mute);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.nav-item svg { display: block; transition: all 0.18s ease; }
.nav-item.active { color: var(--accent); }
.nav-item.active svg { filter: drop-shadow(0 0 8px var(--accent-glow)); }
.nav-item:active { transform: scale(0.94); }

/* ============ TOOL SELECT ============ */
#tool-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2322d3ee' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding: 14px 44px 14px 16px;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 0;
}
.tool-panel { display: none; }
.tool-panel.active { display: block; animation: screenIn 0.3s cubic-bezier(0.22, 1, 0.36, 1); }

/* ============ GOAL FORM OVERLAY ============ */
#goal-form {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  z-index: 200;
  overflow-y: auto;
  padding: 40px 24px;
  animation: sheetUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  z-index: 500;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ PROGRESS BAR ============ */
.progress {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #06b6d4);
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ============ SCROLLBAR ============ */
.screen::-webkit-scrollbar, #goal-form::-webkit-scrollbar { width: 0; }
