:root {
  --fondo: #ffffff;
  /* the panel in the light theme */
  --chiaro-pannello: #ffffff;
  --chiaro-binario: #f1f0ed;
  --chiaro-pillola: #ffffff;
  --chiaro-testo: #121214;
  --chiaro-testo-2: #77767d;
  /* the panel in the dark theme */
  --scuro-pannello: #121316;
  --scuro-binario: #1e2025;
  --scuro-pillola: #2c2f36;
  --scuro-testo: #f3f2ef;
  --scuro-testo-2: #8d8f98;
  /* the orb: sun and moon */
  --sole: #f4a23a;
  --sole-chiaro: #ffd98a;
  --luna: #c9d2ec;
  --luna-chiaro: #f4f6ff;

  /* written by script.js as the theme changes */
  --p-bg: var(--chiaro-pannello);
  --p-track: var(--chiaro-binario);
  --p-pill: var(--chiaro-pillola);
  --p-text: var(--chiaro-testo);
  --p-text-2: var(--chiaro-testo-2);
  --p-line: rgba(18, 18, 20, 0.08);
  --orb: var(--sole);
  --orb-hi: var(--sole-chiaro);
  --glow: rgba(244, 162, 58, 0.34);
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--p-text);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vmin, 40px);
}

.panel {
  position: relative;
  width: min(372px, 100%);
  background: var(--p-bg);
  color: var(--p-text);
  border-radius: 22px;
  padding: clamp(14px, 3.4vh, 20px) clamp(14px, 4vw, 20px) clamp(12px, 3vh, 16px);
  box-shadow:
    0 0 0 1px var(--p-line),
    0 1px 2px rgba(10, 10, 20, 0.05),
    0 10px 24px -12px rgba(10, 10, 20, 0.16),
    0 32px 60px -30px rgba(10, 10, 20, 0.22);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.6vh, 16px);
  overflow: hidden;
  isolation: isolate;
}

/* a thin light along the top edge of the panel */
.panel__sheen {
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, var(--sheen, 0)), transparent);
  pointer-events: none;
}

.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel__title { font-size: 15px; font-weight: 640; letter-spacing: -0.01em; font-stretch: 104%; }
.panel__sub { margin-top: 3px; font-size: 12.5px; color: var(--p-text-2); }

/* the page thumbnail: light, dark or split for Auto */
.thumb {
  position: relative;
  flex: none;
  width: 46px;
  height: 32px;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--p-line), 0 2px 6px -2px rgba(10, 10, 20, 0.18);
}
.thumb__page {
  position: absolute;
  inset: 0;
  padding: 7px 7px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.thumb__page i { display: block; height: 3px; border-radius: 2px; }
.thumb__page i:nth-child(1) { width: 62%; }
.thumb__page i:nth-child(2) { width: 88%; }
.thumb__page i:nth-child(3) { width: 74%; }
.thumb__page--light { background: #fbfaf7; }
.thumb__page--light i { background: #d9d7d1; }
.thumb__page--light i:nth-child(1) { background: var(--sole); }
.thumb__page--dark { background: #17181c; clip-path: inset(0 0 0 100%); }
.thumb__page--dark i { background: #3a3d45; }
.thumb__page--dark i:nth-child(1) { background: var(--luna); }

/* the segmented control */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 48px;
  padding: 4px;
  border-radius: 14px;
  background: var(--p-track);
  box-shadow: inset 0 1px 2px rgba(10, 10, 20, 0.06), inset 0 0 0 1px var(--p-line);
  touch-action: manipulation;
}

.seg__pill, .seg__hover, .seg__glow {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 10px;
  border-radius: 10px;
  pointer-events: none;
}
.seg__hover { background: var(--p-pill); opacity: 0; }
.seg__glow {
  top: -6px;
  bottom: -6px;
  border-radius: 20px;
  background: radial-gradient(60% 70% at 30% 50%, var(--glow), transparent 70%);
  filter: blur(6px);
  opacity: 0.9;
}
.seg__pill {
  background: var(--p-pill);
  box-shadow:
    0 0 0 0.5px var(--p-line),
    0 1px 2px rgba(10, 10, 20, 0.1),
    0 4px 12px -3px rgba(10, 10, 20, 0.16);
  overflow: hidden;
}
/* the top edge of the pill catches the light */
.seg__shine {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, var(--pill-shine, 0.9)) 0, rgba(255, 255, 255, 0) 45%);
  mix-blend-mode: soft-light;
}

.seg__opt {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: var(--w, 520);
  font-stretch: var(--s, 100%);
  letter-spacing: -0.005em;
  color: var(--p-text-2);
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.seg__opt[aria-checked="true"] { color: var(--p-text); }
.seg__opt:focus-visible { box-shadow: 0 0 0 2px var(--p-bg), 0 0 0 4px var(--focus, #6b7cff); }

.ico {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico__fill { fill: currentColor; stroke: none; }

/* the live orb rides over the icon of the chosen segment */
.orb {
  position: absolute;
  z-index: 3;
  left: 0;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  overflow: visible;
  pointer-events: none;
}
.orb [data-rays] line { stroke: var(--orb); stroke-width: 1.7; stroke-linecap: round; }

.note {
  position: relative;
  height: 18px;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--p-text-2);
  padding-left: 2px;
}
.note__line { display: block; white-space: nowrap; }
.note b { font-weight: 600; color: var(--p-text); font-variant-numeric: tabular-nums; }

.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  fill: #111;
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}

@media (max-width: 380px) {
  .seg__opt { gap: 5px; font-size: 13px; }
  .panel__sub { font-size: 12px; }
}
