/* Activeness */

:root {
  --bg: #F1F3EF;
  --ink: #1B241F;
  --muted: #5E6B64;
  --faint: #9AA69F;
  --pale: #DDE3DE;
  --hair: #E1E6E2;
  --accent: #2E6E5A;
  --white: #FFFFFF;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; overflow: hidden; }

#app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--safe-top) + 24px);
  overflow: hidden;
}

button, input {
  font: inherit;
  color: inherit;
}
button {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
a { color: var(--accent); text-decoration: none; }

.grotesk { font-family: "Space Grotesk", Inter, system-ui, sans-serif; }

/* layout ---------------------------------------------------------------- */

.view { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.bar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 24px;
}
.bar .day {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}
.bar.icons { padding: 0 12px 0 8px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: none;
}
.icon-btn.faint { color: var(--faint); }
.icon-btn svg { display: block; }

.center {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tabs {
  height: calc(84px + var(--safe-bottom));
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 48px;
  padding: 10px 24px 0;
}
.tabs .icon-btn { width: 64px; height: 48px; color: var(--ink); }
.tabs .icon-btn.off { color: var(--faint); }

/* star ------------------------------------------------------------------ */

.star {
  display: block;
  width: min(100vw, 390px);
  height: auto;
  flex: none;
}
.star .tri-hit { cursor: pointer; }
.star .tri-hit:focus { outline: none; }
.star .tri-hit:focus-visible .tri-base { stroke: var(--accent); stroke-width: 2; }
.star .ring { fill: var(--white); stroke: var(--hair); stroke-width: 1; filter: url(#starShadow); }
.star .ring.tap { cursor: pointer; }
.star .tri-base { fill: var(--pale); }
.star .tri-fill { fill: var(--accent); transition: d 0.3s ease; }
.star .disc-hi { fill: var(--accent); opacity: 0.5; }
.star .disc-lo { fill: var(--accent); }

.star.small { width: 72px; height: 72px; }
.star.mini  { width: 40px; height: 40px; }
.star.mini .ring, .star.small .ring { filter: none; }

/* spicer ---------------------------------------------------------------- */

.progress { position: relative; width: 56px; height: 56px; flex: none; }

.card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0 28px calc(40px + var(--safe-bottom));
}
.card .cat { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); }
.card .item {
  display: block;
  margin-top: 6px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 38px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card .min { margin-top: 10px; font-size: 15px; line-height: 20px; color: var(--muted); }
.spacer-a { flex: 1.1; }
.spacer-b { flex: 1; }
.spacer-c { flex: 1.6; }

.go {
  width: 60px;
  height: 60px;
  border-radius: 30px;
  color: var(--white);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(46, 110, 90, 0.25);
  margin: 0 auto;
}
.go.busy { opacity: 0.5; pointer-events: none; }
.go.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* range slider: the star taken apart ------------------------------------ */

.range-row { display: flex; align-items: center; gap: 4px; }
.range-row .endtri { width: 28px; height: 28px; flex: none; display: block; }
.range-row .endtri .outline { fill: none; stroke: var(--faint); stroke-width: 1.8; stroke-linejoin: round; }
.range-row .endtri .fill { fill: var(--accent); }

.range-box { position: relative; flex: 1; height: 44px; }
.range-box .track {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 19px;
  height: 6px;
  border-radius: 3px;
  background: var(--pale);
}
.range-box .track .fill {
  position: absolute;
  top: 0;
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}
.range-box .tick {
  position: absolute;
  left: 50%;
  top: 16px;
  width: 2px;
  height: 12px;
  margin-left: -1px;
  border-radius: 1px;
  background: rgba(27, 36, 31, 0.22);
}
.star-range {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  outline: none;
  touch-action: pan-y;
}
.star-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 22px; }
.star-range::-webkit-slider-runnable-track { height: 44px; background: transparent; border: 0; }
.star-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid #CFD6D1;
  box-shadow: 0 2px 8px rgba(27, 36, 31, 0.18);
}
.star-range::-moz-range-track { height: 44px; background: transparent; border: 0; }
.star-range::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid #CFD6D1;
  box-shadow: 0 2px 8px rgba(27, 36, 31, 0.18);
  box-sizing: border-box;
}

/* detail overlay -------------------------------------------------------- */

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(27, 36, 31, 0.28);
  z-index: 10;
  width: 100%;
  height: 100%;
}
.sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(var(--safe-top) + 52px);
  bottom: calc(var(--safe-bottom) + 12px);
  border-radius: 28px;
  background: var(--white);
  box-shadow: 0 24px 60px rgba(27, 36, 31, 0.22);
  z-index: 11;
  display: flex;
  flex-direction: column;
  padding: 26px 28px 32px;
}
.sheet.bg { background: var(--bg); padding: 0; overflow: hidden; }
.sheet .head { display: flex; align-items: flex-start; justify-content: space-between; }
.sheet .title {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 28px;
  line-height: 34px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding-top: 5px;
}
.sheet .head .icon-btn { margin-right: -10px; }
.rows {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 44px;
  padding: 0 0 48px 8px;
}
.row { display: flex; align-items: center; gap: 24px; }
.row .glyph { width: 64px; height: 64px; flex: none; display: block; }
.row .glyph .outline { fill: none; stroke: var(--faint); stroke-width: 2; stroke-linejoin: round; }
.row .glyph .fill { fill: var(--accent); }
.row .label { font-size: 17px; line-height: 22px; font-weight: 500; }
.row .label small { display: block; font-size: 13px; line-height: 18px; font-weight: 400; color: var(--muted); margin-top: 2px; }

/* trends ---------------------------------------------------------------- */

.tf { display: flex; align-items: center; gap: 2px; }
.tf button { height: 44px; padding: 0 12px; font-size: 14px; font-weight: 500; color: var(--faint); }
.tf button.on { color: var(--ink); font-weight: 600; }

.charts {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 24px calc(40px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.charts .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.charts .chart { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.charts .chart .name { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--muted); }
.charts svg { display: block; width: 100%; height: auto; }
.charts .body { fill: var(--accent); }
.charts .body.half { opacity: 0.5; }
.charts .empty { fill: var(--pale); }

/* turtles grid ---------------------------------------------------------- */

.grid-head { height: 60px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 24px; }
.grid-head .word { font-size: 14px; font-weight: 500; color: var(--muted); }
.grid-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 20px 32px; }
.wind { position: relative; margin: 0 auto; }
.wind svg.path { position: absolute; left: 0; top: 0; overflow: visible; }
.wind .path path { fill: none; stroke: #C9D3CC; stroke-width: 2; stroke-linecap: round; }
.wind .turtle { position: absolute; width: 72px; height: 72px; display: block; }
.wind .turtle:focus { outline: none; }
.wind .turtle:focus-visible { outline: 2px solid var(--accent); border-radius: 50%; }

/* swipe ----------------------------------------------------------------- */

.swipe { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.swipe .foot {
  height: calc(140px + var(--safe-bottom));
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px calc(40px + var(--safe-bottom));
}
.swipe .foot .icon-btn { width: 48px; height: 48px; color: var(--faint); }
.swipe .when { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.swipe .when .wd { font-family: "Space Grotesk", Inter, sans-serif; font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -0.01em; }
.swipe .when .dt { font-size: 14px; line-height: 18px; font-weight: 500; color: var(--muted); }
.swipe .star { transition: transform 0.25s ease, opacity 0.25s ease; }
.swipe .star.out-left  { transform: translateX(-24px); opacity: 0; }
.swipe .star.out-right { transform: translateX(24px);  opacity: 0; }

/* admin ----------------------------------------------------------------- */

.admin {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 28px calc(64px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 40px;
}
.admin .group { display: flex; flex-direction: column; gap: 6px; }
.admin .group .cat {
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 22px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.admin .arow { display: flex; align-items: flex-start; gap: 16px; padding: 10px 0; }
.admin .arow svg { flex: none; margin-top: 8px; display: block; }
.admin .arow svg polygon { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-linejoin: round; }
.admin .fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.quiet-input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 2px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.quiet-input.name { font-size: 17px; line-height: 24px; font-weight: 500; color: var(--ink); }
.quiet-input.minimum { font-size: 14px; line-height: 20px; color: var(--muted); }
.quiet-input:focus { border-bottom-color: var(--accent); }
.quiet-input::placeholder { color: #B4BDB7; }
.admin .saved { position: fixed; right: 20px; bottom: calc(20px + var(--safe-bottom)); width: 8px; height: 8px; border-radius: 4px; background: var(--accent); opacity: 0; transition: opacity 0.3s ease; }
.admin .saved.on { opacity: 1; }

/* lock ------------------------------------------------------------------ */

.lock-field {
  width: 220px;
  height: 48px;
  margin: 0 auto;
  padding: 0 16px;
  border: 0;
  border-radius: 24px;
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--hair);
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.2em;
  outline: none;
}
.lock-field:focus { box-shadow: inset 0 0 0 1.5px var(--accent); }
.lock-field.shake { animation: shake 0.4s ease; }
.lock-foot { height: calc(160px + var(--safe-bottom)); flex: none; display: flex; align-items: flex-start; justify-content: center; }

/* misc ------------------------------------------------------------------ */

.hidden { display: none !important; }
.notice {
  margin: auto;
  max-width: 300px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 21px;
}
