/* =========================================================
   TOKENS
   ========================================================= */
:root{
  --mist:      #F5F7F3;
  --paper:     #FFFFFF;
  --pine:      #1E3B37;
  --pine-80:   #2C4C46;
  --sage:      #6B9A8D;
  --sage-dim:  #A9C6BC;
  --clay:      #E3936B;
  --clay-dim:  #F0C6AE;
  --line:      #DCE3DD;
  --ink:       #1B2421;
  --ink-soft:  #57645D;
  --danger:    #C05B4E;

  --font-display: "Fraunces", Georgia, serif;
  --font-body:    "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

  --radius-s:  10px;
  --radius-m:  16px;
  --radius-l:  28px;

  --shadow-card: 0 1px 2px rgba(30,59,55,0.04), 0 12px 28px -12px rgba(30,59,55,0.14);
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }

body{
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* subtle paper grain so the flat mist background isn't dead flat */
.grain{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: radial-gradient(rgba(30,59,55,0.035) 1px, transparent 1px);
  background-size: 3px 3px;
}

.page{
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 64px 24px 80px;
}

/* =========================================================
   HERO
   ========================================================= */
/* =========================================================
   BRAND
   ========================================================= */
.brand{
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 44px;
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}

.brand-mark{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  color: var(--pine);
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px -8px rgba(30,59,55,0.4);
}
.brand-mark svg{ width: 32px; height: 32px; }

.brand-mark::before{
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1px solid var(--sage-dim);
  opacity: 0;
  animation: pulse-ring 2.8s ease-out 1s infinite;
}

.brand-text{
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 5.2vw, 48px);
  letter-spacing: -0.015em;
  line-height: 1;
  background: linear-gradient(100deg, var(--pine) 25%, var(--clay) 50%, var(--pine) 75%);
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: var(--pine);
  -webkit-text-fill-color: transparent;
  animation: shimmer 3.4s ease-in-out 0.3s infinite alternate;
}

.brand-native{
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--sage);
  margin-top: 4px;
}

.hero{
  margin-bottom: 48px;
  animation: rise 0.7s cubic-bezier(.2,.8,.2,1) both;
}

.eyebrow{
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sage);
  margin: 0 0 14px;
}

.hero-title{
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  color: var(--pine);
  margin: 0 0 18px;
}
.hero-title em{
  font-style: italic;
  color: var(--clay);
}

.hero-sub{
  max-width: 52ch;
  color: var(--ink-soft);
  font-size: 16px;
  margin: 0;
}

/* =========================================================
   FORM PANELS
   ========================================================= */
.panel-stack{
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 32px;
  box-shadow: var(--shadow-card);
  animation: rise 0.7s cubic-bezier(.2,.8,.2,1) both;
}
.panel[data-panel="habits"]{ animation-delay: 0.08s; }
.panel[data-panel="balance"]{ animation-delay: 0.16s; }

.panel-head{
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.panel-head h2{
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 21px;
  color: var(--pine);
  margin: 0;
}
.panel-head p{
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.field-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 18px;
}

.field{
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
}

.field label{
  font-size: 13px;
  font-weight: 600;
  color: var(--pine-80);
}
.field label .unit{
  font-weight: 400;
  color: var(--ink-soft);
  font-size: 12px;
}

.field input,
.field select{
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--mist);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  padding: 11px 13px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  appearance: none;
  width: 100%;
}

.field select{
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
                     linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.field input:hover,
.field select:hover{ border-color: var(--sage-dim); }

.field input:focus,
.field select:focus{
  outline: none;
  border-color: var(--sage);
  background: var(--paper);
  box-shadow: 0 0 0 4px rgba(107,154,141,0.15);
}

.field input::placeholder{ color: #9BA69F; }

.field-error{
  display: none;
  font-size: 12px;
  color: var(--danger);
}

.field.invalid input,
.field.invalid select{
  border-color: var(--danger);
  background: #FCF3F1;
}
.field.invalid .field-error{ display: block; }

/* =========================================================
   SUBMIT
   ========================================================= */
.submit-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 8px 4px 0;
}

.submit-note{
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  max-width: 34ch;
}

.btn-primary{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  color: var(--paper);
  background: var(--pine);
  border: none;
  border-radius: 999px;
  padding: 15px 30px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 10px 24px -10px rgba(30,59,55,0.55);
  white-space: nowrap;
}
.btn-primary:hover{ background: var(--pine-80); transform: translateY(-1px); }
.btn-primary:active{ transform: translateY(0); }
.btn-primary:disabled{ cursor: default; opacity: 0.85; }

.btn-spinner{
  display: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
}
.btn-primary.loading .btn-label{ opacity: 0.75; }
.btn-primary.loading .btn-spinner{ display: inline-block; animation: spin 0.75s linear infinite; }

.btn-secondary{
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  color: var(--pine);
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 12px 24px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.btn-secondary:hover{ border-color: var(--sage); background: var(--mist); }

/* =========================================================
   RESULT / GAUGE — signature element
   ========================================================= */
.result{
  margin-top: 40px;
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}

.result-card{
  background: linear-gradient(180deg, var(--pine) 0%, #16302C 100%);
  border-radius: var(--radius-l);
  padding: 44px 32px 36px;
  text-align: center;
  color: var(--paper);
  box-shadow: 0 24px 60px -20px rgba(20,40,37,0.55);
}

.result-eyebrow{
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sage-dim);
  margin: 0 0 18px;
}

.gauge{
  position: relative;
  width: min(280px, 80%);
  margin: 0 auto 8px;
}
.gauge-svg{ width: 100%; display: block; overflow: visible; }

.gauge-track{
  fill: none;
  stroke: rgba(255,255,255,0.14);
  stroke-width: 16;
  stroke-linecap: round;
}

.gauge-fill{
  fill: none;
  stroke: var(--clay);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 314.16; /* half-circumference of the r=100 arc: PI * 100 */
  stroke-dashoffset: 314.16;
  transition: stroke-dashoffset 1.1s cubic-bezier(.16,.9,.28,1), stroke 0.4s ease;
}

.gauge-readout{
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-number{
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
}

.gauge-caption{
  font-size: 11px;
  color: var(--sage-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 6px;
}

.gauge-badge{
  display: inline-block;
  margin: 18px auto 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: var(--paper);
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.gauge-badge.level-low{      background: rgba(107,154,141,0.22); border-color: rgba(107,154,141,0.55); color: #BFE0D4; }
.gauge-badge.level-medium{   background: rgba(217,174,121,0.22); border-color: rgba(217,174,121,0.55); color: #F0D6AE; }
.gauge-badge.level-high{     background: rgba(227,147,107,0.22); border-color: rgba(227,147,107,0.55); color: #F3C1A6; }
.gauge-badge.level-veryhigh{ background: rgba(192,91,78,0.28);   border-color: rgba(192,91,78,0.65);   color: #F5B7AC; }

.result-note{
  max-width: 42ch;
  margin: 22px auto 26px;
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(255,255,255,0.72);
}

.result .btn-secondary{
  color: var(--paper);
  border-color: rgba(255,255,255,0.28);
}
.result .btn-secondary:hover{
  border-color: rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.08);
}

/* =========================================================
   ERROR TOAST
   ========================================================= */
.error-toast{
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: var(--pine);
  color: var(--paper);
  border-left: 4px solid var(--danger);
  padding: 14px 20px;
  border-radius: var(--radius-s);
  font-size: 13.5px;
  max-width: min(92vw, 440px);
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.4);
  z-index: 50;
  animation: toast-in 0.35s cubic-bezier(.2,.8,.2,1) both;
}

/* =========================================================
   FOOTER
   ========================================================= */
.page-footer{
  margin-top: 56px;
  text-align: center;
}
.page-footer p{
  font-size: 12px;
  color: var(--ink-soft);
}
.page-footer code{
  font-family: var(--font-mono);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
}

/* =========================================================
   MOTION
   ========================================================= */
@keyframes rise{
  from{ opacity: 0; transform: translateY(14px); }
  to{ opacity: 1; transform: translateY(0); }
}
@keyframes shimmer{
  from{ background-position: 100% 0; }
  to{ background-position: 0% 0; }
}
@keyframes pulse-ring{
  0%{ transform: scale(0.85); opacity: 0.55; }
  70%{ transform: scale(1.4); opacity: 0; }
  100%{ transform: scale(1.4); opacity: 0; }
}
@keyframes spin{
  to{ transform: rotate(360deg); }
}
@keyframes toast-in{
  from{ opacity: 0; transform: translateX(-50%) translateY(16px); }
  to{ opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 720px){
  .page{ padding: 48px 18px 64px; }
  .panel{ padding: 24px 20px; }
}

@media (max-width: 560px){
  .field-grid{ grid-template-columns: 1fr; }
  .submit-row{ flex-direction: column; align-items: stretch; }
  .btn-primary{ width: 100%; }
  .submit-note{ max-width: none; text-align: center; }
}
