:root {
  --bg: #09100e;
  --bg-2: #0d1713;
  --surface: rgba(255,255,255,.065);
  --surface-strong: rgba(255,255,255,.105);
  --line: rgba(255,255,255,.095);
  --text: #f3f7f5;
  --muted: rgba(226,237,231,.46);
  --muted-2: rgba(226,237,231,.28);
  --accent: #65da8f;
  --accent-soft: rgba(101,218,143,.16);
  --danger: #ff766d;
  --shadow: 0 22px 70px rgba(0,0,0,.38);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { min-height: 100%; background: var(--bg); overscroll-behavior: none; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(80% 55% at 50% 12%, rgba(73,156,110,.16), transparent 68%),
    radial-gradient(65% 55% at 12% 88%, rgba(209,128,64,.09), transparent 72%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  touch-action: manipulation;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
input { font-size: 16px !important; }
svg { display: block; }

.app-shell {
  width: min(100%, 620px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 18px calc(28px + var(--safe-bottom));
  position: relative;
}
.view { display: none; min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 46px); }
.view.active { display: block; animation: viewIn .2s ease both; }
@keyframes viewIn { from { opacity: .45; transform: translateY(4px); } }

.home-head,
.events-head {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 5;
}
.home-head {
  justify-content: flex-start;
  gap: 16px;
}
.home-date {
  color: rgba(240,247,243,.56);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .01em;
  text-transform: lowercase;
}
.round-icon {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255,255,255,.09), rgba(255,255,255,.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 12px 30px rgba(0,0,0,.16);
  display: grid;
  place-items: center;
  padding: 0;
}
.round-icon:active { transform: scale(.94); background: rgba(255,255,255,.10); }
.round-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.dial {
  height: clamp(470px, 70dvh, 640px);
  min-height: 470px;
  position: relative;
  margin: 0 -8px 0;
  isolation: isolate;
  overflow: hidden;
}
.dial-glow,
.dial-arc { display: none; }
.dial-nodes { position: absolute; inset: 0; z-index: 3; }
.event-node {
  position: absolute;
  width: 62px;
  height: 62px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,.13), transparent 38%),
    linear-gradient(145deg, rgba(255,255,255,.10), rgba(255,255,255,.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 14px 34px rgba(0,0,0,.23);
  color: var(--text);
  padding: 0;
  display: grid;
  place-items: center;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
  touch-action: manipulation;
}
.event-node:active { transform: translate(-50%, -50%) scale(.91); background: rgba(255,255,255,.12); }
.event-node__glyph {
  font-size: 23px;
  line-height: 1;
  font-weight: 650;
  letter-spacing: -.03em;
  transform: translateY(-1px);
}
.event-node__label {
  position: absolute;
  left: 50%;
  top: calc(100% + 7px);
  transform: translateX(-50%);
  font-size: 8px;
  line-height: 1;
  color: rgba(232,241,236,.32);
  font-weight: 650;
  letter-spacing: .03em;
  white-space: nowrap;
  text-transform: lowercase;
}
.event-node.is-done-today::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(101,218,143,.4);
  pointer-events: none;
}
.activity-gauge {
  --activity-color: #d98b50;
  position: absolute;
  right: -34px;
  bottom: -58px;
  width: 290px;
  height: 290px;
  z-index: 1;
  pointer-events: none;
  filter: saturate(1.05);
}
.activity-gauge__blob,
.activity-gauge__core {
  position: absolute;
  border-radius: 50%;
  mix-blend-mode: screen;
}
.activity-gauge__blob {
  filter: blur(26px);
  opacity: .8;
  animation: blobFloat 11s ease-in-out infinite alternate;
}
.activity-gauge__blob--a {
  inset: 42px 18px 26px 52px;
  background: radial-gradient(circle at 36% 34%, color-mix(in srgb, var(--activity-color) 72%, #fff 8%), transparent 48%), radial-gradient(circle at 64% 58%, rgba(12,34,27,.92), transparent 62%);
}
.activity-gauge__blob--b {
  inset: 18px 44px 62px 14px;
  background: radial-gradient(circle at 58% 42%, color-mix(in srgb, var(--activity-color) 48%, #6be2a2 16%), transparent 42%), radial-gradient(circle at 42% 65%, rgba(18,42,34,.86), transparent 64%);
  animation-duration: 14s;
  animation-direction: alternate-reverse;
}
.activity-gauge__blob--c {
  inset: 74px 2px 8px 88px;
  background: radial-gradient(circle at 34% 44%, color-mix(in srgb, var(--activity-color) 60%, #ffe0a8 10%), transparent 38%), radial-gradient(circle at 60% 60%, rgba(11,24,20,.9), transparent 58%);
  filter: blur(34px);
  animation-duration: 17s;
}
.activity-gauge__core {
  inset: 48px;
  background:
    radial-gradient(circle at 34% 32%, color-mix(in srgb, var(--activity-color) 24%, transparent), transparent 30%),
    radial-gradient(circle at 55% 52%, rgba(14,28,23,.94), rgba(4,9,8,.98) 74%);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.02),
    0 0 34px color-mix(in srgb, var(--activity-color) 22%, transparent),
    0 0 74px color-mix(in srgb, var(--activity-color) 14%, transparent);
  animation: corePulse 7s ease-in-out infinite;
}
@keyframes blobFloat {
  from { transform: translate3d(-8px, 8px, 0) scale(.96); }
  to   { transform: translate3d(10px, -10px, 0) scale(1.05); }
}
@keyframes corePulse {
  0%,100% { transform: scale(.98); }
  50% { transform: scale(1.035); }
}
.home-foot {
  min-height: 20px;
  margin-top: -10px;
  text-align: center;
  color: rgba(231,241,235,.26);
  font-size: 10px;
  font-weight: 620;
  letter-spacing: .02em;
}

.events-head h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 18px;
  letter-spacing: -.02em;
  font-weight: 700;
}
.events-head__actions { display: flex; gap: 8px; }
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 18px -18px 18px;
  padding: 0 18px 4px;
}
.filters::-webkit-scrollbar { display: none; }
.filter-dot {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: rgba(238,246,242,.48);
  font-size: 14px;
  font-weight: 720;
}
.filter-dot.active { color: #07100c; background: #d9efe2; border-color: transparent; }
.event-list { display: grid; gap: 20px; padding-bottom: calc(22px + var(--safe-bottom)); }
.day-group { display: grid; gap: 7px; }
.day-title { padding-left: 3px; color: rgba(232,241,236,.32); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.event-row {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  gap: 11px;
  align-items: center;
  min-height: 62px;
  border-radius: 22px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.075);
  background: linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 12px 26px rgba(0,0,0,.12);
}
.event-row__icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.055);
  color: rgba(243,248,245,.72);
  font-size: 15px;
  font-weight: 700;
}
.event-row__title { font-size: 14px; font-weight: 690; line-height: 1.2; }
.event-row__detail { margin-top: 3px; color: rgba(232,241,236,.39); font-size: 11px; line-height: 1.35; word-break: break-word; }
.event-row__side { display: flex; align-items: center; gap: 4px; }
.event-row__time { color: rgba(232,241,236,.34); font-size: 11px; font-variant-numeric: tabular-nums; }
.event-row__delete {
  width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: rgba(232,241,236,.22); font-size: 16px; padding: 0;
}
.empty-state { text-align: center; color: rgba(232,241,236,.16); font-size: 64px; padding: 24vh 0 0; }

.sheet-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgba(1,5,3,.58);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
.sheet {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 620px);
  max-height: min(78dvh, 680px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 9px 20px calc(22px + var(--safe-bottom));
  border-radius: 34px 34px 0 0;
  border: 1px solid rgba(255,255,255,.08);
  border-bottom: 0;
  background:
    radial-gradient(70% 38% at 50% 0%, rgba(103,210,144,.08), transparent 70%),
    rgba(13,20,17,.985);
  box-shadow: 0 -30px 80px rgba(0,0,0,.44);
  animation: sheetIn .2s cubic-bezier(.2,.8,.2,1);
}
.sheet--compact { max-height: min(65dvh, 520px); }
.sheet--comment { max-height: min(54dvh, 400px); }
@keyframes sheetIn { from { transform: translate(-50%, 18px); opacity: .55; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.12); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.sheet-head h2 { margin: 0; font-size: 25px; font-weight: 710; letter-spacing: -.04em; }
.sheet-kicker { margin-bottom: 3px; color: rgba(232,241,236,.34); font-size: 10px; font-weight: 700; text-transform: lowercase; }
.sheet-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.07); color: rgba(238,246,242,.46); font-size: 24px; line-height: 1; padding: 0; }
.amount-line { display: flex; align-items: baseline; gap: 8px; padding: 3px 2px 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.amount-input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; font-size: 48px !important; font-weight: 700; letter-spacing: -.055em; padding: 0; }
.amount-line > span { color: rgba(236,244,240,.38); font-size: 22px; font-weight: 650; }
.segment-grid { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; margin: 15px -20px 0; padding: 0 20px 4px; }
.segment-grid::-webkit-scrollbar { display: none; }
.segment-grid button,
.water-choice button {
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 999px;
  background: rgba(255,255,255,.055);
  padding: 10px 13px;
  white-space: nowrap;
  color: rgba(239,246,242,.58);
  font-size: 12px;
  font-weight: 650;
}
.segment-grid button.selected { background: rgba(220,240,228,.92); color: #09110d; border-color: transparent; }
.comment-field { display: block; margin: 17px 0 14px; }
.comment-field > span { display: block; margin: 0 0 7px 3px; color: rgba(232,241,236,.28); font-size: 10px; font-weight: 650; }
.comment-field input {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 18px;
  outline: none;
  background: rgba(255,255,255,.05);
  padding: 13px 15px;
  font-size: 16px !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}
.comment-field input:focus { border-color: rgba(101,218,143,.34); background: rgba(255,255,255,.065); }
.comment-field--large { margin-top: 2px; }
.comment-field--large input { min-height: 62px; font-size: 17px !important; }
.primary-action {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #dcefe3, #a8d9ba);
  color: #08100c;
  box-shadow: 0 12px 34px rgba(91,183,126,.16);
  font-size: 14px;
  font-weight: 760;
}
.food-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.food-choice button {
  min-height: 112px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.food-choice button span { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.06); display: grid; place-items: center; font-size: 14px; font-weight: 720; }
.food-choice button strong { font-size: 13px; color: rgba(242,248,245,.72); }
.water-choice { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.water-choice button { padding: 13px 4px; }
.data-actions { display: grid; gap: 8px; }
.data-actions button {
  min-height: 54px;
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 19px;
  background: rgba(255,255,255,.045);
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  text-align: left;
  padding: 8px 12px;
}
.data-actions button > span { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.055); color: rgba(238,246,242,.5); }
.data-actions button strong { font-size: 13px; color: rgba(242,248,245,.7); }
.data-actions button.danger strong, .data-actions button.danger > span { color: var(--danger); }

.micro-toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  min-height: 44px;
  max-width: calc(100% - 28px);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 999px;
  background: rgba(18,27,23,.92);
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px 5px 14px;
  animation: toastIn .15s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 7px); } }
.micro-toast > span { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: rgba(244,249,246,.72); font-size: 12px; font-weight: 670; }
.micro-toast button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255,255,255,.07); color: rgba(244,249,246,.62); font-size: 15px; padding: 0; }

@media (max-width: 390px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .dial { margin-left: -4px; margin-right: -4px; height: clamp(440px, 68dvh, 580px); }
  .event-node { width: 58px; height: 58px; }
  .event-node__glyph { font-size: 21px; }
  .activity-gauge { width: 250px; height: 250px; right: -36px; bottom: -48px; }
  .filters { margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .sheet { padding-left: 16px; padding-right: 16px; }
  .water-choice { grid-template-columns: repeat(2,1fr); }
}
@media (max-height: 700px) {
  .dial { height: 430px; min-height: 430px; }
  .event-node { width: 58px; height: 58px; }
  .activity-gauge { width: 240px; height: 240px; right: -32px; bottom: -46px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Fixed thumb-path slots: lower-left to upper-right. */
.event-node.pos-0 { left: 18%; top: 72%; }
.event-node.pos-1 { left: 26%; top: 55%; }
.event-node.pos-2 { left: 37%; top: 40%; }
.event-node.pos-3 { left: 51%; top: 28%; }
.event-node.pos-4 { left: 67%; top: 21%; }
.event-node.pos-5 { left: 83%; top: 17%; }
.activity-gauge.activity-level-0 { --activity-color: #d07a46; }
.activity-gauge.activity-level-1 { --activity-color: #dc8f4d; }
.activity-gauge.activity-level-2 { --activity-color: #d6aa52; }
.activity-gauge.activity-level-3 { --activity-color: #aac85f; }
.activity-gauge.activity-level-4 { --activity-color: #77d476; }
.activity-gauge.activity-level-5 { --activity-color: #56e091; }
body.sheet-open { overflow: hidden; }
