:root {
  color-scheme: light;
  --ink: #17171c;
  --muted: #757581;
  --subtle: #a1a1ad;
  --paper: #f7f7fb;
  --card: #ffffff;
  --line: #e7e7ed;
  --purple: #6255dc;
  --purple-dark: #4539b8;
  --purple-soft: #eceafd;
  --green: #28b889;
  --shadow: 0 14px 36px rgba(28, 24, 68, 0.1);
  --small-shadow: 0 4px 16px rgba(29, 27, 58, 0.07);
  font-family: Inter, ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #ececf3; color: var(--ink); }
body { overscroll-behavior: none; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, [role="button"] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(98, 85, 220, .28);
  outline-offset: 2px;
}

#app { min-height: 100vh; }
.app-shell {
  width: min(100%, 470px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px rgba(25,25,40,.04), 0 20px 80px rgba(30,25,80,.12);
}
.status-pad { height: max(14px, env(safe-area-inset-top)); flex: none; }
.screen {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 20px 126px;
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }

.icon-button {
  border: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.icon-button.soft { background: #fff; box-shadow: var(--small-shadow); }
.icon-button:active { transform: scale(.94); }
.icon-button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.large-heading {
  margin: 15px 0 5px;
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: -1.35px;
  font-weight: 800;
}
.eyebrow {
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-size: 11px;
  font-weight: 800;
}
.subtext { color: var(--muted); font-size: 14px; line-height: 1.45; }
.section-label {
  margin: 25px 0 10px;
  font-size: 18px;
  letter-spacing: -.35px;
  font-weight: 760;
}
.section-label-row { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.section-label-row .section-label { margin: 0; }
.text-button {
  border: 0;
  background: transparent;
  color: var(--purple);
  font-weight: 700;
  font-size: 13px;
  padding: 7px 0;
  cursor: pointer;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 17px 0 18px;
}
.day-button {
  border: 0;
  background: transparent;
  min-width: 0;
  padding: 8px 2px;
  border-radius: 18px;
  color: var(--muted);
  cursor: pointer;
}
.day-button .dow { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; margin-bottom: 7px; }
.day-button .date { display: grid; place-items: center; margin: auto; width: 33px; height: 33px; border-radius: 50%; font-size: 13px; font-weight: 750; }
.day-button.today .dow { color: var(--purple); }
.day-button.selected { color: #fff; background: var(--purple); box-shadow: 0 6px 16px rgba(98,85,220,.26); }
.day-button.selected .dow { color: #fff; }

.active-card {
  color: white;
  border-radius: 25px;
  padding: 20px;
  min-height: 160px;
  background:
    radial-gradient(circle at 84% 18%, rgba(255,255,255,.19) 0 18%, transparent 19%),
    linear-gradient(135deg, #7063e8, #4b3dc2);
  box-shadow: 0 18px 34px rgba(71,55,188,.24);
  position: relative;
  overflow: hidden;
}
.active-card::after {
  content: "";
  position: absolute;
  width: 150px; height: 150px;
  border: 24px solid rgba(255,255,255,.07);
  border-radius: 50%;
  right: -67px; bottom: -94px;
}
.active-card.idle {
  color: var(--ink);
  min-height: 137px;
  background: linear-gradient(135deg, #fff, #f2f0ff);
  box-shadow: var(--small-shadow);
  border: 1px solid #eeecfa;
}
.active-card.idle::after { border-color: rgba(98,85,220,.06); }
.active-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.active-label { font-size: 12px; font-weight: 750; opacity: .82; letter-spacing: .35px; }
.pulse { width: 9px; height: 9px; background: #79ffd4; border-radius: 50%; box-shadow: 0 0 0 6px rgba(121,255,212,.14); }
.timer { margin: 14px 0 2px; font-variant-numeric: tabular-nums; font-size: 38px; line-height: 1; font-weight: 670; letter-spacing: -1.5px; position: relative; z-index: 1; }
.active-name { opacity: .85; font-size: 14px; position: relative; z-index: 1; }
.stop-button {
  position: absolute;
  right: 18px; bottom: 18px; z-index: 2;
  border: 0; border-radius: 17px;
  background: rgba(255,255,255,.96);
  color: var(--purple-dark);
  padding: 11px 17px;
  font-weight: 750;
  box-shadow: 0 6px 20px rgba(25,10,80,.18);
  cursor: pointer;
}
.idle-cta { margin-top: 12px; font-size: 26px; letter-spacing: -.8px; font-weight: 790; }
.idle-hint { color: var(--muted); font-size: 13px; margin-top: 4px; }

.view-toggle {
  display: inline-flex;
  background: #eaeaef;
  padding: 3px;
  border-radius: 11px;
}
.view-toggle button {
  width: 34px; height: 30px; border: 0; background: transparent; border-radius: 8px; color: var(--muted); cursor: pointer;
}
.view-toggle button.active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(30,30,60,.08); }

.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.category-grid.list { grid-template-columns: 1fr; }
.category-card {
  position: relative;
  min-height: 78px;
  background: #fff;
  border: 1px solid #ebebf0;
  border-radius: 17px;
  padding: 15px 13px 13px 20px;
  text-align: left;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(24,22,54,.035);
}
.category-card::before { content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 7px; background: var(--cat); }
.category-card.active { border-color: var(--cat); box-shadow: 0 7px 20px color-mix(in srgb, var(--cat) 24%, transparent); }
.category-title { display: block; font-size: 15px; font-weight: 710; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.category-total { display: block; color: var(--muted); margin-top: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.category-card.active .category-total { color: var(--cat); font-weight: 720; }
.add-category {
  border: 1px dashed #cfcddc;
  background: transparent;
  min-height: 78px;
  border-radius: 17px;
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 1px 12px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid #dfdfe7;
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 680;
  cursor: pointer;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.empty-state {
  margin: 56px auto 0;
  max-width: 280px;
  text-align: center;
  color: var(--muted);
}
.empty-art {
  width: 104px; height: 104px; margin: 0 auto 23px; border-radius: 32px;
  background: linear-gradient(145deg, #efedff, #fff);
  display: grid; place-items: center; color: var(--purple);
  box-shadow: var(--small-shadow);
}
.empty-art svg { width: 49px; height: 49px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.empty-state :is(h2,h3) { margin: 0 0 8px; color: var(--ink); font-size: 19px; letter-spacing: -.3px; }
.empty-state p { margin: 0; font-size: 14px; line-height: 1.5; }
.primary-button {
  border: 0; border-radius: 16px; color: #fff;
  background: var(--purple);
  padding: 13px 18px; font-weight: 760;
  box-shadow: 0 8px 18px rgba(98,85,220,.23); cursor: pointer;
}
.primary-button:active { transform: translateY(1px); }
.empty-state .primary-button { margin-top: 19px; }

.event-group-title {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 18px 1px 9px;
  font-weight: 780; font-size: 14px;
}
.event-group-title span { font-weight: 600; color: var(--muted); font-size: 12px; }
.event-list { display: grid; gap: 9px; }
.event-card {
  border: 0; width: 100%; background: #fff; border-radius: 17px;
  display: grid; grid-template-columns: 7px 58px 1fr auto;
  gap: 12px; align-items: center; min-height: 72px; padding: 0 13px 0 0;
  overflow: hidden; text-align: left; box-shadow: var(--small-shadow); cursor: pointer;
}
.event-rail { background: var(--cat); align-self: stretch; }
.event-time { font-size: 12px; line-height: 1.35; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.event-name { font-size: 14px; font-weight: 720; margin-bottom: 4px; }
.event-category { color: var(--muted); font-size: 11px; }
.duration-pill { color: var(--purple-dark); background: var(--purple-soft); padding: 6px 8px; border-radius: 9px; font-size: 11px; font-weight: 740; }

.timeline-summary {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  border-radius: 21px; background: #fff; padding: 17px 18px; box-shadow: var(--small-shadow); margin: 6px 0 17px;
}
.summary-total { font-size: 27px; font-weight: 790; letter-spacing: -.8px; }
.summary-label { color: var(--muted); font-size: 12px; margin-top: 3px; }
.donut {
  width: 58px; height: 58px; border-radius: 50%;
  background: conic-gradient(var(--purple) 0 61%, #24b58b 61% 79%, #f4b747 79% 91%, #e9e9ef 91%);
  display: grid; place-items: center;
}
.donut::after { content: ""; width: 37px; height: 37px; border-radius: 50%; background: #fff; }
.breakdown-card { background: #fff; border-radius: 21px; padding: 18px; box-shadow: var(--small-shadow); }
.range-toggle { display: grid; grid-template-columns: repeat(3,1fr); background: #ececf1; padding: 3px; border-radius: 12px; }
.range-toggle button { border: 0; background: transparent; padding: 8px 5px; border-radius: 9px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.range-toggle button.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(25,25,50,.08); }
.bar-chart { height: 138px; display: flex; align-items: end; gap: 8px; border-bottom: 1px solid #e5e5ea; padding: 15px 3px 0; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 5px; }
.bar-stack { width: 100%; max-width: 26px; min-height: 3px; border-radius: 7px 7px 2px 2px; overflow: hidden; display: flex; flex-direction: column-reverse; }
.bar-segment { width: 100%; min-height: 2px; }
.bar-day { color: var(--muted); font-size: 9px; }
.legend { display: flex; flex-wrap: wrap; gap: 9px 12px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--cat); }

.goal-summary {
  border-radius: 24px; padding: 20px; margin: 7px 0 20px;
  background: linear-gradient(135deg, #1d1c28, #343047); color: white;
  display: flex; justify-content: space-between; align-items: center;
}
.goal-summary strong { display: block; font-size: 31px; line-height: 1; letter-spacing: -1.2px; }
.goal-summary span { display: block; opacity: .67; margin-top: 6px; font-size: 12px; }
.goal-ring { width: 69px; height: 69px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#8d80ff var(--progress), rgba(255,255,255,.12) 0); }
.goal-ring::before { content: attr(data-label); display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: #2d293d; font-size: 12px; font-weight: 780; }
.period-title { margin: 21px 1px 10px; display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; font-weight: 780; }
.period-title span { color: var(--muted); font-size: 11px; font-weight: 600; }
.goal-card { background: #fff; border-radius: 18px; padding: 14px 15px; box-shadow: var(--small-shadow); margin-bottom: 9px; cursor: pointer; }
.goal-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.goal-name { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 720; }
.goal-dot { width: 10px; height: 10px; border-radius: 4px; background: var(--cat); }
.goal-percent { font-size: 12px; color: var(--muted); font-weight: 700; }
.progress-track { height: 6px; border-radius: 10px; background: #ececf0; margin: 12px 0 7px; overflow: hidden; }
.progress-fill { height: 100%; width: min(100%, var(--progress)); border-radius: inherit; background: var(--cat); }
.goal-meta { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }

.settings-profile { margin-bottom: 24px; }
.app-mark { width: 52px; height: 52px; border-radius: 16px; overflow: hidden; box-shadow: 0 8px 20px rgba(77,61,191,.2); }
.app-mark img { width: 100%; height: 100%; }
.settings-section-title { margin: 21px 4px 8px; color: var(--muted); font-size: 11px; font-weight: 780; text-transform: uppercase; letter-spacing: .9px; }
.settings-group { background: #fff; border-radius: 19px; overflow: hidden; box-shadow: var(--small-shadow); }
.setting-row {
  min-height: 58px; width: 100%; border: 0; border-bottom: 1px solid #ececf1; background: #fff;
  display: grid; grid-template-columns: 35px 1fr auto; gap: 9px; align-items: center;
  padding: 7px 14px; text-align: left; cursor: pointer;
}
.setting-row:last-child { border-bottom: 0; }
.setting-icon { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: var(--icon-bg, #efedff); color: var(--icon-color, var(--purple)); font-size: 15px; }
.setting-label strong { display: block; font-size: 13px; }
.setting-label span { color: var(--muted); font-size: 10px; margin-top: 2px; display: block; }
.chevron { color: #b7b7c0; font-size: 20px; }
.danger { color: #df4f5c; }

.tabbar-wrap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 13px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--paper) 25%);
  z-index: 20; pointer-events: none;
}
.tabbar {
  height: 72px;
  border: 1px solid rgba(219,219,228,.86);
  border-radius: 25px;
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(18px);
  box-shadow: 0 9px 30px rgba(30,28,62,.13);
  display: grid; grid-template-columns: repeat(5,1fr);
  padding: 8px 4px 7px; pointer-events: auto;
}
.tab-button {
  border: 0; background: transparent; color: #9696a2; border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 0; font-size: 9px; font-weight: 690; cursor: pointer; position: relative;
}
.tab-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.tab-button.active { color: var(--purple); }
.tab-button.active::before { content: ""; position: absolute; top: -3px; width: 19px; height: 3px; border-radius: 3px; background: var(--purple); }
.tab-badge { position: absolute; top: 1px; margin-left: 19px; min-width: 14px; height: 14px; padding: 0 3px; display: grid; place-items: center; border-radius: 7px; background: #f05b68; color: #fff; font-size: 8px; border: 2px solid white; }

.fab {
  position: fixed;
  z-index: 18;
  bottom: calc(97px + env(safe-area-inset-bottom));
  left: calc(50% + min(175px, 39vw) - 54px);
  width: 52px; height: 52px; border: 0; border-radius: 18px; background: var(--purple); color: white;
  display: grid; place-items: center; font-size: 28px; box-shadow: 0 10px 25px rgba(80,64,199,.3); cursor: pointer;
}
.fab:active { transform: scale(.95); }

.modal-backdrop {
  position: fixed; z-index: 100; inset: 0;
  background: rgba(21,19,32,.32);
  backdrop-filter: blur(5px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  width: min(100%, 470px);
  max-height: 91dvh; overflow-y: auto;
  background: var(--paper); border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 60px rgba(24,22,54,.2);
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .5; } }
.sheet-handle { width: 38px; height: 5px; border-radius: 4px; background: #d0d0d8; margin: 1px auto 14px; }
.sheet-header { display: grid; grid-template-columns: 60px 1fr 60px; align-items: center; margin-bottom: 16px; }
.sheet-header h2 { margin: 0; text-align: center; font-size: 18px; }
.sheet-action { border: 0; background: transparent; color: var(--purple); font-weight: 720; cursor: pointer; }
.sheet-action.left { text-align: left; color: var(--muted); }
.form-field { display: block; margin: 12px 0; }
.form-field > span { display: block; color: var(--muted); font-size: 11px; font-weight: 720; margin: 0 3px 6px; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; border: 1px solid #e3e3e9; border-radius: 14px; background: #fff;
  padding: 13px 14px; color: var(--ink);
}
.form-field textarea { resize: vertical; min-height: 84px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 1px; }
.color-option { width: 31px; height: 31px; border-radius: 11px; border: 3px solid var(--paper); background: var(--color); box-shadow: 0 0 0 1px #d9d9df; cursor: pointer; }
.color-option.selected { box-shadow: 0 0 0 3px var(--ink); }
.category-editor-row { display: grid; grid-template-columns: 8px 1fr auto; gap: 11px; align-items: center; background: white; border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.editor-color { align-self: stretch; border-radius: 5px; background: var(--cat); }
.editor-actions button { border: 0; background: transparent; color: var(--muted); padding: 6px; cursor: pointer; }
.editor-actions .danger { color: #df4f5c; }
.sheet-footer { display: flex; gap: 10px; margin-top: 20px; }
.sheet-footer button { flex: 1; }
.secondary-button { border: 1px solid #dcdce5; border-radius: 16px; background: #fff; padding: 12px 16px; font-weight: 720; cursor: pointer; }
.danger-button { border: 0; border-radius: 16px; background: #fff0f1; color: #d94150; padding: 12px 16px; font-weight: 720; cursor: pointer; }

#toast-root { position: fixed; z-index: 200; left: 50%; bottom: 103px; transform: translateX(-50%); width: min(90%, 380px); pointer-events: none; }
.toast { background: rgba(31,29,42,.94); color: #fff; padding: 12px 16px; border-radius: 15px; text-align: center; font-size: 13px; box-shadow: 0 8px 25px rgba(0,0,0,.2); animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (min-width: 700px) {
  body { padding: 20px 0; }
  .app-shell { min-height: calc(100dvh - 40px); height: calc(100dvh - 40px); border-radius: 38px; }
  .fab { left: calc(50% + 175px - 54px); bottom: 117px; }
  .modal-sheet { border-radius: 28px; margin-bottom: 18px; max-height: calc(100dvh - 40px); }
  .modal-backdrop { align-items: center; }
}
@media (max-width: 360px) {
  .screen { padding-left: 15px; padding-right: 15px; }
  .large-heading { font-size: 29px; }
  .timer { font-size: 34px; }
}
