:root {
  --bg: #f6f2ea;
  --ink: #14130f;
  --ink-soft: #4a4740;
  --card: #ffffff;
  --border: #e6dfd1;
  --accent: #3d7a5c;
  --accent-soft: #e4efe8;
  --radius: 14px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.app-header h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

section {
  margin-top: 1.75rem;
}

.week-overview {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem 1.4rem;
}

.week-overview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.week-overview-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.week-percent {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
}

.week-bar-track {
  margin-top: 0.7rem;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.week-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.week-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}

.week-day {
  text-align: center;
  padding: 0.5rem 0.25rem;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.week-day.is-today {
  border-color: var(--accent);
}

.week-day .label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.week-day .value {
  display: block;
  margin-top: 0.25rem;
  font-weight: 700;
  font-size: 0.95rem;
}

.add-habit form {
  display: flex;
  gap: 0.6rem;
}

.add-habit input {
  flex: 1;
  padding: 0.75rem 0.9rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}

.add-habit input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.add-habit button {
  padding: 0.75rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.add-habit button:hover {
  filter: brightness(0.95);
}

.habits {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.empty-state {
  text-align: center;
  color: var(--ink-soft);
  padding: 2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.habit-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 1.15rem;
}

.habit-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.habit-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.habit-name {
  margin: 0;
  font-size: 1.05rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.habit-streak {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.habit-streak.active {
  color: var(--accent);
}

.habit-delete {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
}

.habit-delete:hover {
  color: #a5504a;
}

.habit-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.day-toggle {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--ink-soft);
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease;
}

.day-toggle:hover {
  transform: translateY(-1px);
}

.day-toggle.is-today {
  border-color: var(--accent);
}

.day-toggle.is-done {
  color: #fff;
  border-color: transparent;
}

@media (max-width: 420px) {
  .week-days .label {
    font-size: 0.62rem;
  }
  .add-habit form {
    flex-direction: column;
  }
}
