:root {
  --bg: #f6f0e1;
  --bg-accent: #d7e2d2;
  --surface: rgba(255, 250, 243, 0.88);
  --surface-strong: #fffdf8;
  --text: #1e2b23;
  --muted: #617168;
  --primary: #0f8f63;
  --primary-contrast: #f8fff9;
  --danger: #b5483c;
  --border: rgba(30, 43, 35, 0.1);
  --shadow: 0 30px 60px rgba(23, 48, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.82), transparent 28%),
    linear-gradient(145deg, var(--bg), var(--bg-accent));
}

button,
input,
select {
  font: inherit;
}

.page {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 24px;
}

.hero,
.panel,
.summary-card,
.habit-card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero,
.panel {
  border-radius: 28px;
  padding: 24px;
  margin-bottom: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.eyebrow,
.summary-label,
.meta-label,
.progress-label,
.history-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 10px;
  font-size: clamp(34px, 7vw, 52px);
  line-height: 0.98;
}

h2 {
  margin-top: 8px;
  font-size: 24px;
}

h3 {
  font-size: 22px;
}

.subtitle {
  max-width: 560px;
  margin-top: 14px;
  line-height: 1.6;
  color: var(--muted);
}

.hero-meta {
  min-width: 180px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
}

.meta-note {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.summary-card {
  padding: 20px;
  border-radius: 22px;
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.panel-actions,
.filter-row,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.habit-form {
  display: grid;
  gap: 12px;
  grid-template-columns: 2fr 2fr 100px 84px 220px;
}

input,
select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--text);
}

input[type="color"] {
  padding: 6px;
}

.select-control {
  min-width: 180px;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: var(--primary);
  color: var(--primary-contrast);
}

.ghost-btn {
  background: rgba(30, 43, 35, 0.08);
  color: var(--text);
}

.ghost-btn.is-active {
  background: rgba(15, 143, 99, 0.14);
  color: var(--primary);
}

.danger-btn {
  background: rgba(181, 72, 60, 0.12);
  color: var(--danger);
}

.habit-list {
  display: grid;
  gap: 14px;
}

.habit-card {
  padding: 18px;
  border-radius: 22px;
}

.habit-top,
.habit-bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.habit-top {
  margin-bottom: 14px;
}

.habit-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.habit-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.habit-description {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.habit-meta {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

.habit-side {
  text-align: right;
}

.progress-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.progress-stack {
  display: grid;
  gap: 10px;
}

.progress-track {
  width: 180px;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(30, 43, 35, 0.08);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.habit-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-strip {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.history-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.history-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(30, 43, 35, 0.12);
}

.history-dot.is-complete {
  background: var(--primary);
}

.history-dot.is-partial {
  background: rgba(15, 143, 99, 0.35);
}

.history-dot.is-empty {
  background: rgba(30, 43, 35, 0.08);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.status-pill.is-complete,
.habit-card.is-complete {
  background: rgba(15, 143, 99, 0.08);
}

.status-pill.is-complete {
  color: var(--primary);
}

.status-pill.is-pending {
  background: rgba(30, 43, 35, 0.08);
  color: var(--muted);
}

.empty-state,
.debug-box {
  border-radius: 18px;
  background: #15211c;
  color: #def7e8;
}

.empty-state {
  padding: 22px;
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
}

.debug-box {
  margin: 0;
  padding: 18px;
  min-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero,
  .habit-top,
  .habit-bottom,
  .panel-header,
  .panel-actions,
  .filter-row,
  .form-actions,
  .history-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .habit-form {
    grid-template-columns: 1fr;
  }

  .progress-track {
    width: 100%;
  }

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

  .history-dots {
    justify-content: space-between;
  }
}
