:root {
  --bg: #ffffff;
  --surface: #f4f6f4;
  --text: #1a2b22;
  --muted: #5c6f65;
  --accent: #1e7e4f;
  --accent-strong: #145c39;
  --danger: #b3261e;
  --border: #d9e2dc;
  --radius: 10px;
  --max-width: 640px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

.site-header,
.container,
.site-footer {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: 16px;
}

.site-header {
  padding-top: 2rem;
}

.site-header h1 {
  margin: 0;
  font-size: 2rem;
}

.today-date {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.summary {
  font-weight: 700;
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}

.add-form label {
  flex-basis: 100%;
  font-weight: 600;
}

.add-form input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.625rem 1rem;
}

.add-form button {
  background: var(--accent);
  color: #fff;
}

.add-form button:hover {
  background: var(--accent-strong);
}

.habit-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.habit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.habit-name {
  flex: 1 1 10rem;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.streaks {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--muted);
}

.check-btn {
  min-width: 7.5rem;
  min-height: 3rem;
  font-size: 1rem;
  font-weight: 700;
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.check-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.delete-btn {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}

.delete-btn:hover {
  border-color: var(--danger);
}

.empty-state {
  color: var(--muted);
}

.empty-state[hidden],
.habit-list:empty {
  display: none;
}

.site-footer {
  padding-block: 2rem;
  color: var(--muted);
  font-size: 0.875rem;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .site-header,
  .container,
  .site-footer {
    padding-inline: 16px;
  }

  .habit-row {
    flex-direction: column;
    align-items: stretch;
  }

  .check-btn,
  .delete-btn {
    width: 100%;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101713;
    --surface: #1a2420;
    --text: #e8f0ea;
    --muted: #a9bdb1;
    --accent: #4cc38a;
    --accent-strong: #7fe0ac;
    --danger: #ff8a80;
    --border: #2c3a33;
  }

  .add-form button {
    color: #06281a;
  }

  .check-btn {
    color: var(--accent-strong);
  }

  .check-btn[aria-pressed="true"] {
    background: var(--accent);
    color: #06281a;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none;
  }
}
