* {
  box-sizing: border-box;
}

:root {
  --bg: #f7f7f5;
  --ink: #111111;
  --muted: #898984;
  --line: #d9d9d5;
  --task: #111111;
  --penalty: #9c3b50;
  --card: #ffffff;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  touch-action: manipulation;
}

.app-shell {
  position: relative;
  height: 100svh;
  max-width: 700px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 1px;
}

.person-button,
.icon-button {
  background: transparent;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 999px;
}

.person-button {
  font-weight: 750;
}

.person-icon {
  font-size: 14px;
}

.chevron {
  color: var(--muted);
}

.icon-button {
  font-size: 18px;
  width: 36px;
  justify-content: center;
}

#statsButton {
  font-size: 23px;
  transform: rotate(-12deg);
}

.today {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding-top: 8px;
  padding-bottom: 72px;
}

.task-area,
.habit-area {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-content: flex-start;
  overflow-y: auto;
  scrollbar-width: none;
}

.task-area::-webkit-scrollbar,
.habit-area::-webkit-scrollbar {
  display: none;
}

.task-area {
  flex: 0 1 auto;
  min-height: 36px;
  max-height: 36vh;
}

.habit-area {
  flex: 1 1 auto;
  min-height: 36px;
  max-height: 50vh;
}

.divider {
  width: 100%;
  height: 1px;
  background: var(--line);
  flex: 0 0 1px;
}

.pill {
  position: relative;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 14px;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1;
  font-weight: 760;
  transition: transform .14s ease, opacity .14s ease, filter .14s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.pill:active {
  transform: scale(.95);
}

.task-pill {
  background: var(--task);
  color: #fff;
}

.habit-pill {
  color: #13211c;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04);
}

.penalty-pill {
  background: var(--penalty);
  color: #fff;
}

.pill.dragging {
  transition: none;
}

.overdue-badge {
  position: relative;
  top: -.38em;
  margin-left: 4px;
  font-size: .72em;
  font-weight: 850;
  opacity: .78;
}

.deadline-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .68;
  vertical-align: middle;
}

.add-button {
  position: fixed;
  right: max(18px, calc((100vw - 700px) / 2 + 18px));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  z-index: 20;
}

.success-state {
  position: absolute;
  inset: 42px 0 0;
  padding: 0 28px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.success-state::before {
  content: "";
  position: absolute;
  inset: 7% 4% 12%;
  border-radius: 42px;
  background: radial-gradient(circle at 28% 30%, rgba(242, 194, 207, .68), transparent 34%),
    radial-gradient(circle at 72% 38%, rgba(185, 220, 243, .72), transparent 33%),
    radial-gradient(circle at 50% 72%, rgba(201, 232, 193, .70), transparent 38%),
    #f0eee8;
  filter: blur(1px);
}

.success-orb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .58);
  box-shadow: 0 20px 60px rgba(35, 35, 30, .10), inset 0 0 0 1px rgba(255, 255, 255, .75);
  backdrop-filter: blur(16px);
  margin-bottom: 28px;
}

.success-orb::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 33px;
  font-weight: 500;
}

.success-copy {
  position: relative;
  max-width: 360px;
}

.success-kicker,
.modal-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .12em;
}

.success-copy h1 {
  margin: 8px 0 10px;
  font-size: clamp(31px, 8vw, 44px);
  line-height: .98;
  letter-spacing: -.045em;
}

.success-copy p {
  margin: 0;
  color: #5d5d59;
  font-size: 15px;
  line-height: 1.45;
}

.auth-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f7f7f5, #eceae5);
  z-index: 200;
}

.auth-card {
  width: min(92vw, 440px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 28px;
  padding: 28px 22px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.10);
}

.auth-brand {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 850;
  font-size: 10px;
}

.auth-card h1 {
  margin: 10px 0 8px;
  font-size: clamp(30px, 7vw, 40px);
  letter-spacing: -.05em;
}

.auth-subtitle {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #efefeb;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}

.auth-tab {
  background: transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--muted);
}

.auth-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 7px;
}

.auth-form label span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 850;
}

.auth-button {
  margin-top: 8px;
}

.auth-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(156, 59, 80, 0.08);
  color: var(--penalty);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.popover {
  position: fixed;
  z-index: 50;
  background: rgba(255, 255, 255, .96);
  border: 1px solid #e6e6e1;
  border-radius: 15px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, .12);
  padding: 6px;
  min-width: 140px;
  backdrop-filter: blur(18px);
}

.popover button {
  width: 100%;
  text-align: left;
  background: transparent;
  border-radius: 10px;
  padding: 10px 11px;
  font-weight: 700;
}

.person-menu {
  top: 51px;
  left: 12px;
}

.add-menu {
  right: max(18px, calc((100vw - 700px) / 2 + 18px));
  bottom: 81px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .25);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-card {
  width: min(100%, 700px);
  max-height: 92svh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px max(22px, env(safe-area-inset-bottom));
  box-shadow: 0 -18px 70px rgba(0, 0, 0, .10);
}

.compact-card {
  padding-bottom: max(26px, env(safe-area-inset-bottom));
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 2px 0 0;
  font-size: 22px;
  letter-spacing: -.025em;
}

.close-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e9e9e4;
  font-size: 23px;
  color: #111;
}

form,
.field-stack {
  display: grid;
  gap: 13px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
}

label>span,
legend,
.settings-section h3,
.move-date-label>span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 850;
}

input,
select {
  width: 100%;
  padding: 12px;
  border: 1px solid #deded9;
  background: #fff;
  border-radius: 12px;
  outline: none;
  color: #111;
}

input:focus,
select:focus {
  border-color: #aaa9a3;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.audience-picker,
.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audience-picker button,
.weekday-picker button {
  flex: 1;
  min-width: 52px;
  background: #fff;
  border: 1px solid #deded9;
  border-radius: 11px;
  padding: 10px 8px;
  font-weight: 750;
}

.audience-picker button.selected,
.weekday-picker button.selected {
  background: #111;
  color: #fff;
  border-color: #111;
}

.two-col,
.interval-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-note {
  margin: -4px 1px 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.save-button,
.reset-button,
.choice-button {
  width: 100%;
  background: #111;
  color: #fff;
  border-radius: 13px;
  padding: 13px;
  font-weight: 820;
}

.choice-button {
  margin-bottom: 12px;
  background: #fff;
  color: #111;
  border: 1px solid #deded9;
}

.move-date-label {
  margin-bottom: 12px;
}

.form-warning {
  color: var(--penalty);
  min-height: 0;
  font-size: 13px;
  font-weight: 750;
}

.settings-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.settings-section:first-of-type {
  border-top: 0;
}

.settings-section h3 {
  margin: 0 0 10px;
}

.settings-section p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-toggle-row,
.section-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-headline h3 {
  margin: 0;
}

.text-button {
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  color: #111;
  padding: 6px 0;
}

.toggle-button {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d8d8d2;
  padding: 3px;
  position: relative;
  transition: background .15s ease;
}

.toggle-button::after {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}

.toggle-button.on {
  background: #111;
}

.toggle-button.on::after {
  transform: translateX(18px);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-swatch {
  aspect-ratio: 1;
  border-radius: 11px;
  border: 2px solid transparent;
}

.color-swatch.selected {
  border-color: #111;
  box-shadow: inset 0 0 0 2px #fff;
}

.category-setting,
.manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
}

.category-left,
.manage-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.category-dot {
  width: 20px;
  height: 20px;
  border-radius: 7px;
  flex: 0 0 auto;
}

.manage-actions {
  display: flex;
  gap: 5px;
}

.manage-row button,
.category-setting button {
  background: #e9e9e4;
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 750;
}

.manage-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.stats-intro {
  margin: -3px 0 18px;
  color: #66645f;
  font-size: 14px;
  line-height: 1.45;
}

.stats-group {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}

.stats-group:first-of-type {
  border-top: 0;
}

.stats-group h3 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -.02em;
}

.stats-positive {
  margin: 0 0 14px;
  color: #6c6b66;
  font-size: 13px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e6e6e1;
  border-radius: 16px;
  padding: 13px 14px;
  margin-top: 8px;
}

.stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.stat-name {
  font-weight: 780;
}

.stat-number {
  font-size: 13px;
  color: #5e5d59;
  white-space: nowrap;
}

.stat-note {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 85px;
  transform: translateX(-50%);
  z-index: 200;
  background: #111;
  color: white;
  padding: 9px 10px 9px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
}

.toast-action {
  border-radius: 999px;
  background: #fff;
  color: #111;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 850;
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
}

@media (max-width: 380px) {
  .pill {
    font-size: 12px;
    padding: 8px 10px;
  }

  .task-area,
  .habit-area {
    gap: 5px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }
}