/* Clean white “pie counter” aesthetic */
:root{
  --bg:#ffffff;
  --ink:#151515;
  --muted:#5b5b5b;
  --card:#ffffff;
  --shadow: 0 18px 60px rgba(0,0,0,.10);
  --shadow-soft: 0 10px 30px rgba(0,0,0,.08);
  --radius: 16px;
  --focus: 0 0 0 3px rgba(0,0,0,.12);
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; background:var(--bg); color:var(--ink); }
body{
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  overflow:hidden; /* single-window, no scrolling */
}

#app{ height:100%; width:100%; display:flex; flex-direction:column; }

.topbar{
  position:relative;
  z-index:10;
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  padding:18px 18px 8px 18px;
}

.title{
  margin:0;
  font-family: Fredoka, system-ui, sans-serif;
  font-weight:700;
  font-size: clamp(22px, 3.2vw, 44px);
  letter-spacing: .2px;
  line-height:1.05;
  text-shadow: 0 2px 0 rgba(0,0,0,.04);
}

.attrib-btn{
  margin-top:2px;
  border:1px solid rgba(0,0,0,.14);
  background:#fff;
  padding:10px 12px;
  border-radius: 999px;
  font-weight:600;
  cursor:pointer;
  box-shadow: var(--shadow-soft);
}
.attrib-btn:focus{ outline:none; box-shadow: var(--shadow-soft), var(--focus); }

.stage{
  position:relative;
  flex:1;
  min-height:0;
  padding: 0 12px 14px 12px;
}

#viz{
  height:100%;
  width:100%;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(0,0,0,.02), rgba(0,0,0,0));
  overflow:hidden;
}

/* Tooltip */
.tooltip{
  position:absolute;
  z-index:20;
  min-width: 220px;
  max-width: 320px;
  padding: 12px 12px 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  transform: translate(-50%, -110%);
  pointer-events:none; /* click-through */
}
.tooltip[aria-hidden="true"]{ display:none; }
.tooltip-title{
  font-weight:700;
  font-size: 14px;
  margin-bottom: 6px;
}
.tooltip-body{
  font-size: 13px;
  color: var(--ink);
  line-height:1.35;
}
.tooltip-footnote{
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

/* Loading overlay */
.loading{
  position:absolute;
  inset:0;
  z-index:30;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(255,255,255,.86);
}
.loading[hidden]{ display:none; }
.loading-card{
  padding: 18px 18px 16px 18px;
  border-radius: 16px;
  background:#fff;
  border:1px solid rgba(0,0,0,.10);
  box-shadow: var(--shadow);
  text-align:center;
  width: min(420px, 92vw);
}
.spinner{
  width: 26px;
  height: 26px;
  margin: 0 auto 10px auto;
  border-radius: 999px;
  border: 3px solid rgba(0,0,0,.10);
  border-top-color: rgba(0,0,0,.55);
  animation: spin 900ms linear infinite;
}
@keyframes spin{ to { transform: rotate(360deg); } }
.loading-text{ font-weight:700; }
.loading-sub{ margin-top:4px; font-size:12px; color:var(--muted); }

/* Modal */
.modal{ position:fixed; inset:0; z-index:50; display:none; }
.modal[aria-hidden="false"]{ display:block; }
.modal-backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.28);
}
.modal-card{
  position:relative;
  width: min(560px, 92vw);
  margin: 10vh auto 0 auto;
  background:#fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.12);
  overflow:hidden;
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 14px 10px 14px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.modal-head h2{ margin:0; font-size: 16px; }
.modal-close{
  border:none; background:transparent;
  font-size:18px; cursor:pointer;
  width:36px; height:36px; border-radius:10px;
}
.modal-close:focus{ outline:none; box-shadow: var(--focus); }
.modal-body{
  padding: 12px 14px 14px 14px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}
.modal-body a{ color: inherit; }
.modal-body .small{ color: var(--muted); font-size: 12px; }

/* SVG focus ring for keyboard users */
.state:focus{ outline:none; filter: drop-shadow(0 6px 18px rgba(0,0,0,.18)); }