:root{
  /* ---- shared tokens (identity that doesn't change with theme) ---- */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
 
  /* pillar / variable identity colors — same in both themes */
  --c-social: #C1633F;   /* warm coral/red   */
  --c-study:  #C79A3A;   /* golden/yellow    */
  --c-sleep:  #4F7089;   /* muted blue       */
  --c-active: #5E8A5A;   /* muted green      */
  --c-depression: #7C5C74; /* muted plum, respectful, non-alarming */
  --c-warning: #B4472F;  /* high-stress tone */
  --c-accent: #C79A3A;
 
  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 22px;
  --ease: cubic-bezier(.4,0,.2,1);
}
 
/* ---- DARK THEME (default) ---- */
[data-theme="dark"]{
  --bg: #14171E;
  --bg-raised: #1C202A;
  --bg-card: #20242F;
  --bg-sunken: #10131A;
  --text: #EDE8DC;
  --text-dim: #A6A395;
  --text-faint: #706C60;
  --border: rgba(237,232,220,0.09);
  --border-strong: rgba(237,232,220,0.16);
  --shadow: 0 18px 45px rgba(0,0,0,0.45);
  --stage-glow: radial-gradient(60% 55% at 50% 20%, rgba(199,154,58,0.10), transparent 70%);
}
 
/* ---- LIGHT THEME ---- */
[data-theme="light"]{
  --bg: #F4EFE4;
  --bg-raised: #EAE3D3;
  --bg-card: #FBF8F0;
  --bg-sunken: #E5DDC9;
  --text: #241F17;
  --text-dim: #5C5748;
  --text-faint: #8B8575;
  --border: rgba(36,31,23,0.10);
  --border-strong: rgba(36,31,23,0.18);
  --shadow: 0 18px 40px rgba(90,70,40,0.14);
  --stage-glow: radial-gradient(60% 55% at 50% 20%, rgba(199,154,58,0.14), transparent 70%);
}
 
*{ box-sizing: border-box; }
html{ scroll-behavior: smooth; }
 
body{
  margin: 0;
  background:
    var(--stage-glow),
    radial-gradient(50% 40% at 88% 8%, rgba(79,112,137,0.09), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
  transition: background .35s var(--ease), color .35s var(--ease);
  overflow-x: hidden;
}
 
h1, h2, h3{ font-family: var(--font-display); font-weight: 600; margin: 0 0 .5em; }
 
/* ==========================================================
   THEME TOGGLE + RESET
   ========================================================== */
#theme-toggle{
  position: fixed;
  top: calc(var(--nav-h, 60px) + 18px); right: 24px;
  z-index: 60;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: var(--shadow);
}
#theme-toggle:focus-visible, .skip-reset:focus-visible, button:focus-visible{
  outline: 2px solid var(--c-study);
  outline-offset: 2px;
}
.theme-icon{ font-size: 1rem; }
 
.skip-reset{
  position: fixed;
  top: calc(var(--nav-h, 60px) + 20px); right: 150px;
  z-index: 60;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  background: transparent;
}
.skip-reset:hover{ color: var(--text); }
 
/* ==========================================================
   FLOATING AVATAR — fixed to the right edge of the viewport,
   small and gently bobbing, visible across every section.
   ========================================================== */
.floating-avatar{
  position: fixed;
  top: 50%;
  right: 22px;
  z-index: 40;
  width: 160px;          /* was 120px */
  transform: translateY(-50%);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.25));
  animation: avatar-float 5s ease-in-out infinite;
  transition: filter .2s var(--ease);
}
.floating-avatar:active{ cursor: grabbing; }
.floating-avatar.is-dragging{
  cursor: grabbing;
  animation: none;
  filter: drop-shadow(0 16px 30px rgba(0,0,0,0.4));
}
/* Once the user has dropped the avatar somewhere, it keeps that
   left/top position (set inline by script.js) instead of the
   default fixed corner, and stops the idle bob so it doesn't
   drift from where it was placed. */
.floating-avatar.is-positioned{ animation: none; }
#student-svg{
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
@keyframes avatar-float{
  0%, 100%{ transform: translateY(-50%) translateY(0px); }
  50%{ transform: translateY(-50%) translateY(-10px); }
}
 
@media (max-width: 900px){
  .floating-avatar{ width: 112px; right: 12px; top: auto; bottom: 18px; transform: none; animation: avatar-float-mobile 5s ease-in-out infinite; }  /* was 84px */
  .floating-avatar.is-positioned{ animation: none; }
  @keyframes avatar-float-mobile{
    0%, 100%{ transform: translateY(0px); }
    50%{ transform: translateY(-8px); }
  }
}
 
/* ==========================================================
   SECTIONS — shared scaffolding
   ========================================================== */
.story-section{
  padding: 90px 24px;
  display: flex;
  justify-content: center;
}
.section-inner{ width: 100%; max-width: 1080px; }
.section-inner.narrow{ max-width: 660px; }
.section-inner.center{ text-align: center; }
 
/* ==========================================================
   PAGE HEADLINE — sits above the research-question section as
   the title for the whole piece.
   ========================================================== */
.page-header{
  padding: 64px 24px 0;
  text-align: center;
}
.page-headline{
  font-size: clamp(1.8rem, 4.2vw, 3.1rem);
  line-height: 1.18;
  max-width: 900px;
  margin: 0 auto;
  background: linear-gradient(90deg, var(--c-sleep), var(--c-study) 55%, var(--c-social));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
 
/* ==========================================================
   RESEARCH QUESTION — opening section of the page
   ========================================================== */
.research-section{ padding-top: 60px; padding-bottom: 50px; min-height: 52vh; align-items: center; }
 
.research-tag{
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  margin-bottom: 24px;
}
 
.research-card{
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  padding: 64px 56px 60px;
  max-width: 820px;
  margin: 0 auto;
  overflow: hidden;
}
.research-card::before{
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--c-sleep), var(--c-study) 50%, var(--c-social));
}
.research-card .research-tag{ margin-bottom: 22px; }

.research-question{
  font-size: clamp(1.4rem, 3vw, 2.35rem);
  line-height: 1.28;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}
 
.research-intro{
  color: var(--text-dim);
  font-size: 0.95rem;
  max-width: 480px;
  margin: 18px auto 0;
}
 
.site-footer{ text-align:center; padding: 30px 24px 60px; color: var(--text-faint); font-size: 0.76rem; }
 
/* ==========================================================
   DASHBOARD SECTIONS (day clock / pressure profile)
   ========================================================== */
.dashboard-section{ padding-top: 50px; }
.dashboard-title{ font-size: clamp(1.6rem, 3.2vw, 2.3rem); max-width: 640px; }
 
.dashboard-grid{
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  margin-top: 36px;
  align-items: start;
}
.dashboard-main{
  display: flex;
  flex-direction: column;
  gap: 20px;
}
 
.chart-card{
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
  padding: 26px 28px 24px;
}
.chart-card-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.chart-card-head h4{
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}
.chart-card-sub{ font-size: 0.78rem; color: var(--text-faint); }
.chart-card-select{
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-family: var(--font-body);
}
 
.clock-layout{ display: flex; justify-content: center; }
#day-clock-svg{ width: 100%; max-width: 560px; height: auto; }
 
.radar-layout{ display: grid; grid-template-columns: 1fr 210px; gap: 20px; align-items: center; }
#pressure-radar-svg{ width: 100%; height: auto; }
.radar-table table{ border-collapse: collapse; width: 100%; font-size: 0.76rem; }
.radar-table td{ padding: 6px 6px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.radar-table .rt-label{ color: var(--text-faint); }
 
.insight-box{
  margin-top: 26px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--c-accent);
  border-radius: var(--radius-s);
  padding: 14px 18px;
  font-size: 0.88rem;
  color: var(--text-dim);
  max-width: 780px;
  min-height: 1px;
}
.insight-box:empty{ display: none; }
 
/* ==========================================================
   MODERN FILTER PANEL
   ========================================================== */
.filter-panel{
  position: sticky;
  top: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.filter-heading{
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.filter-group{ display: flex; flex-direction: column; gap: 8px; }
.filter-label{
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.filter-label b{ color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
 
.filter-toggle-row{
  display: flex;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.filter-toggle{
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.filter-toggle:hover{ color: var(--text); }
.filter-toggle.is-active{ background: var(--c-accent); color: #1A1A16; }
 
.filter-range{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--bg-sunken);
  outline: none;
  cursor: pointer;
}
.filter-range::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: pointer;
}
.filter-range::-moz-range-thumb{
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--c-accent);
  border: 2px solid var(--bg-card);
  cursor: pointer;
}
 
.filter-select{
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.82rem;
}
 
.filter-reset{
  appearance: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.filter-reset:hover{ color: var(--text); border-color: var(--text-dim); }
 
.filter-note{
  font-size: 0.72rem;
  color: var(--text-faint);
  margin: 0;
  text-align: center;
}
 
/* ---- Shared tooltip (used by scatter, clock, jitter, radar) ---- */
.viz-tooltip{
  position: fixed;
  pointer-events: none;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 8px 12px;
  font-size: 0.78rem;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .15s var(--ease);
}
.viz-tooltip b{ color: var(--c-study); }
.viz-tooltip .tt-row{ display: flex; justify-content: space-between; gap: 12px; }
 
/* ==========================================================
   ACCESSIBILITY — reduced motion
   ========================================================== */
@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html{ scroll-behavior: auto; }
}
 
/* ==========================================================
   LARGE SCREENS — laptop / desktop.
   Wider stage, a two-up layout for the clock + scatter pair so
   the page uses the extra horizontal room instead of stretching
   one narrow column down the middle, and everything scales up
   a step so it reads as sized-for-the-screen rather than a phone
   layout stretched wide.
   ========================================================== */
@media (min-width: 1180px){
  .section-inner{ max-width: 1280px; }
  .dashboard-grid{ grid-template-columns: 280px 1fr; gap: 36px; }
  .chart-card{ padding: 32px 34px 30px; }
  .chart-card-head h4{ font-size: 1.22rem; }

}

@media (min-width: 1500px){
  .section-inner{ max-width: 1440px; }
  .dashboard-grid{ grid-template-columns: 300px 1fr; gap: 44px; }
  .story-section{ padding: 110px 40px; }
  .dashboard-section{ padding-top: 60px; }
}
 
/* ==========================================================
   RESPONSIVE — smaller screens
   ========================================================== */
@media (max-width: 900px){
  .dashboard-grid{ grid-template-columns: 1fr; }
  .filter-panel{ position: static; }
  .radar-layout{ grid-template-columns: 1fr; }
}
 
@media (max-width: 600px){
  .story-section{ padding: 60px 16px; }
  .page-header{ padding: 88px 16px 0; }
  .research-section{ padding-top: 40px; }
  #theme-toggle{ top: calc(var(--nav-h, 60px) + 10px); right: 14px; padding: 7px 12px; font-size: 0.7rem; }
  .theme-label{ display:none; }
  .skip-reset{ top: calc(var(--nav-h, 60px) + 10px); right: 60px; padding: 7px 12px; font-size: 0.7rem; }
}