:root {
  --paper: #f3eee4;
  --paper-deep: #ebe4d6;
  --card: #fffaf2;
  --ink: #1a1714;
  --mute: #6a6358;
  --rule: #d9d0c2;
  --accent: #b04e34;
  --accent-ink: #7a2f1e;
  --ok: #3d5c45;
  --danger: #8f2f24;
  --shadow: 0 10px 28px rgba(40, 28, 18, 0.08);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: "Source Sans 3", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input {
  font: inherit;
  color: inherit;
}

.app {
  min-height: 100dvh;
  padding:
    calc(22px + var(--safe-t))
    calc(20px + var(--safe-r))
    calc(112px + var(--safe-b))
    calc(20px + var(--safe-l));
  max-width: 460px;
  margin: 0 auto;
}

.top { padding-top: 6px; }

.wordmark {
  margin: 0 0 18px;
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-weight: 560;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--mute);
}

.date {
  margin: 0;
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 560;
  font-size: clamp(34px, 9vw, 46px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.lede {
  margin: 10px 0 0;
  color: var(--mute);
  font-size: 16px;
}

.list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.habit {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 12px 4px 12px 14px;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
  width: 100%;
}

.habit:focus-visible,
.add:focus-visible,
.trash:focus-visible,
.ghost:focus-visible,
.danger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.mark svg { display: block; }

.row.done .mark {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffaf2;
}

.row.done .habit-name {
  color: var(--ink);
}

.habit-name {
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-size: 20px;
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.meta {
  margin-top: 3px;
  font-size: 13px;
  color: var(--mute);
}

.side {
  display: flex;
  align-items: center;
  padding-right: 8px;
  gap: 2px;
}

.streak {
  min-width: 36px;
  text-align: right;
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  color: var(--ink);
  padding: 0 4px;
}

.streak[data-zero="1"] { color: var(--mute); opacity: 0.7; }

.trash {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--mute);
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.trash:active { background: var(--paper-deep); }

.empty {
  margin: 40px 4px 0;
}

.empty-title {
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-size: 24px;
  font-weight: 560;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.empty-copy {
  margin: 0;
  color: var(--mute);
  max-width: 28ch;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding:
    12px
    calc(16px + var(--safe-r))
    calc(14px + var(--safe-b))
    calc(16px + var(--safe-l));
  background: linear-gradient(180deg, rgba(243, 238, 228, 0) 0%, var(--paper) 18%);
  max-width: 460px;
  margin: 0 auto;
}

.composer input {
  flex: 1;
  min-height: 48px;
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
}

.composer input:focus {
  border-color: var(--ink);
}

.add {
  min-height: 48px;
  min-width: 88px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  cursor: pointer;
}

.add:active { transform: translateY(1px); }

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, 0.36);
  display: grid;
  place-items: end center;
  padding: 0 12px calc(18px + var(--safe-b));
  z-index: 20;
}

.sheet[hidden] { display: none; }

.sheet-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 22px;
  padding: 22px 20px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}

.sheet-title {
  font-family: "Fraunces", ui-serif, Georgia, serif;
  font-size: 24px;
  font-weight: 560;
  margin: 0 0 6px;
}

.sheet-copy {
  margin: 0 0 18px;
  color: var(--mute);
}

.sheet-actions {
  display: flex;
  gap: 8px;
}

.ghost, .danger {
  flex: 1;
  min-height: 48px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
}

.ghost {
  background: var(--paper-deep);
  color: var(--ink);
}

.danger {
  background: var(--danger);
  color: #fff8f4;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 540px) {
  .app { padding-top: calc(36px + var(--safe-t)); }
}


.who {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--mute);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
}

.logout {
  color: var(--mute);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.logout:hover { color: var(--ink); }

a.login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-top: 28px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

a.login-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
