/* ============================================================
   Know Thyself — web design system
   Dark celestial theme: deep indigo night sky, gold + violet.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg-0: #07060f;
  --bg-1: #0d0b1d;
  --bg-2: #16132b;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --card-hover: rgba(255, 255, 255, 0.08);
  --text: #ece9f7;
  --text-dim: #a49fc0;
  --text-faint: #6f6a8c;
  --gold: #e3b458;
  --gold-soft: rgba(227, 180, 88, 0.16);
  --violet: #8b6ff0;
  --violet-soft: rgba(139, 111, 240, 0.18);
  --rose: #e07a9a;
  --teal: #5fc7b4;
  --danger: #e0655f;
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Inter", -apple-system, system-ui, sans-serif;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --max-w: 560px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* --- starfield backdrop -------------------------------------------------- */
#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(139, 111, 240, 0.16), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(227, 180, 88, 0.07), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
}
.star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  opacity: 0.7;
  animation: twinkle 4s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.85; }
}

/* --- app shell ------------------------------------------------------------ */
#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 22px 110px;
  flex: 1;
  animation: fadein 0.35s ease;
}
.screen.wide { max-width: 880px; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* --- typography ------------------------------------------------------------ */
h1, h2, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
h1 { font-size: 2.3rem; margin-bottom: 10px; }
h2 { font-size: 1.55rem; margin-bottom: 8px; }
h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.sub { color: var(--text-dim); font-size: 0.98rem; margin-bottom: 26px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 14px;
}
.center { text-align: center; }

/* --- progress bar (onboarding) --------------------------------------------- */
.progress-track {
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0 34px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--violet), var(--gold));
  transition: width 0.4s ease;
}

/* --- top bar ---------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 40px;
}
.back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 8px 10px 8px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.back-btn:hover { color: var(--text); }

/* --- inputs ------------------------------------------------------------------ */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
input[type="text"], input[type="email"], input[type="tel"],
input[type="date"], input[type="time"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 15px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 1.05rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  color-scheme: dark;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--violet);
  background: var(--violet-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { min-height: 130px; resize: vertical; }

.input-row { display: flex; gap: 10px; }
.input-row > * { flex: 1; }

/* --- buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 22px;
  border: none;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 1.02rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s, box-shadow 0.2s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, #b48ff7 0%, var(--violet) 45%, #6a4fd8 100%);
  color: #fff;
  box-shadow: 0 6px 28px rgba(139, 111, 240, 0.35);
}
.btn-primary:hover { box-shadow: 0 8px 34px rgba(139, 111, 240, 0.5); }

.btn-gold {
  background: linear-gradient(135deg, #f2cd7c, var(--gold) 60%, #c99436);
  color: #241a05;
  box-shadow: 0 6px 28px rgba(227, 180, 88, 0.3);
}

.btn-ghost {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--card-hover); }

.btn-danger { background: rgba(224, 101, 95, 0.14); color: var(--danger); border: 1px solid rgba(224, 101, 95, 0.35); }

.btn-inline { width: auto; padding: 10px 20px; font-size: 0.9rem; }

.sticky-cta {
  position: sticky;
  bottom: 20px;
  margin-top: 30px;
  z-index: 5;
}

/* --- cards ---------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  backdrop-filter: blur(8px);
}
.card.clickable { cursor: pointer; transition: background 0.15s, transform 0.15s, border-color 0.15s; }
.card.clickable:hover { background: var(--card-hover); transform: translateY(-2px); border-color: rgba(255,255,255,0.18); }

.card-title-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.card-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--violet-soft);
  flex-shrink: 0;
}
.card p { color: var(--text-dim); font-size: 0.92rem; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

/* --- number / result displays ------------------------------------------------------ */
.big-number {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 40px rgba(227, 180, 88, 0.4);
}
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  flex: 1;
  min-width: 130px;
  text-align: center;
  padding: 18px 12px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--card-border);
}
.stat .value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
}
.stat .label { font-size: 0.75rem; color: var(--text-dim); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 4px; }

/* --- reading prose ------------------------------------------------------------------- */
.reading {
  font-size: 1.02rem;
  color: var(--text);
}
.reading h3 { color: var(--gold); font-family: var(--font-display); font-size: 1.35rem; margin: 22px 0 8px; }
.reading p { margin-bottom: 14px; color: #d8d4ea; }
.reading strong { color: var(--gold); }
.reading em { color: var(--violet); font-style: normal; }
.reading ul { margin: 0 0 14px 20px; color: #d8d4ea; }
.reading li { margin-bottom: 6px; }

/* --- pill choices ----------------------------------------------------------------------- */
.pill-group { display: flex; flex-wrap: wrap; gap: 10px; }
.pill {
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 0.98rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { background: var(--card-hover); }
.pill.selected {
  background: var(--violet-soft);
  border-color: var(--violet);
  color: #cabdff;
  font-weight: 600;
}

/* --- home folder tabs ------------------------------------------------------------------------ */
.home-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 20px 0 0;
  padding: 0 2px;
  border-bottom: 1px solid var(--card-border);
}
.home-tabs::-webkit-scrollbar { display: none; }
.home-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  white-space: nowrap;
  border: 1px solid var(--card-border);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  background: var(--card);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  position: relative;
  top: 1px;
}
.home-tab:hover { color: var(--text); background: var(--card-hover); }
.home-tab.active {
  color: var(--gold);
  background: var(--gold-soft);
  border-color: rgba(227, 180, 88, 0.45);
  border-bottom: 1px solid var(--bg-0);
}
.home-tabs + div { padding-top: 24px; }

/* --- bottom tab bar ------------------------------------------------------------------------ */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 8, 22, 0.88);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.tab {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border: none;
  background: none;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 12px;
  transition: color 0.15s;
}
.tab .tab-icon { font-size: 21px; }
.tab.active { color: var(--gold); }
.tab:hover { color: var(--text-dim); }
.tab.active:hover { color: var(--gold); }

/* --- misc ------------------------------------------------------------------------------------ */
.spinner {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.divider {
  display: flex; align-items: center; gap: 14px;
  color: var(--text-faint); font-size: 0.8rem;
  margin: 22px 0;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--card-border);
}

.error-text { color: var(--danger); font-size: 0.9rem; margin-top: 10px; }
.hint { color: var(--text-faint); font-size: 0.85rem; margin-top: 10px; }

.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--gold-soft);
  color: var(--gold);
}
.badge.violet { background: var(--violet-soft); color: #c3b3ff; }

.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);
  background: #262040;
  border: 1px solid var(--card-border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 0.92rem;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: fadein 0.25s ease;
  max-width: 90vw;
}

/* modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(4, 3, 10, 0.7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein 0.2s ease;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 440px;
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

/* landing hero */
.hero {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
}
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  background: linear-gradient(120deg, #f4e3bb, var(--gold) 40%, #b48ff7 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 18px;
}
.hero .sub { max-width: 430px; font-size: 1.08rem; }
.hero .btn { max-width: 320px; }

.glyph {
  font-size: 44px;
  margin-bottom: 22px;
  filter: drop-shadow(0 0 18px rgba(227, 180, 88, 0.5));
}

@media (max-width: 480px) {
  h1 { font-size: 1.9rem; }
  .screen { padding: 20px 18px 110px; }
}
