:root {
  --background: #f6f7f4;
  --surface: #ffffff;
  --text: #1f2923;
  --muted: #66736b;
  --line: #d9ded8;
  --accent: #2f7d59;
  --accent-strong: #256846;
  --danger: #b84a4a;
  --danger-strong: #963838;
  --focus: #c0d8ca;
  --shadow: 0 24px 70px rgba(32, 41, 36, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(246, 247, 244, 0.9), rgba(238, 242, 239, 0.95)),
    var(--background);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.goal-panel {
  width: min(100%, 760px);
  padding: clamp(24px, 6vw, 48px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.app-header {
  margin-bottom: 32px;
}

.eyebrow,
.section-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 4.2rem;
  line-height: 0.95;
  letter-spacing: 0;
}

.today-date {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 600;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.stat-item {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 16px;
  background: #fbfcfa;
}

.stat-item strong {
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
}

.stat-item span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  line-height: 1.25;
}

.goal-form {
  display: grid;
  gap: 14px;
}

label {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 750;
  line-height: 1.25;
}

textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--text);
  line-height: 1.5;
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--focus);
}

textarea::placeholder {
  color: #8a958f;
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

button:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.primary-button {
  width: 100%;
  background: var(--text);
  color: #ffffff;
}

.primary-button:hover {
  background: #334039;
}

.app-notice {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid #cbd8d0;
  border-radius: 8px;
  background: #f1f6f3;
  color: var(--accent-strong);
  font-weight: 750;
  line-height: 1.4;
}

.app-notice.error {
  border-color: #ead1d1;
  background: #fbf0f0;
  color: var(--danger-strong);
}

.goal-card {
  display: grid;
  gap: 22px;
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.saved-goal {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.status-message {
  min-height: 28px;
  color: var(--muted);
  font-weight: 700;
}

.status-message.done {
  color: var(--accent-strong);
}

.status-message.missed {
  color: var(--danger-strong);
}

.decision-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.decision-button {
  color: #ffffff;
}

.decision-button.done {
  background: var(--accent);
}

.decision-button.done:hover,
.decision-button.done.is-selected {
  background: var(--accent-strong);
  box-shadow: 0 12px 24px rgba(47, 125, 89, 0.2);
}

.decision-button.missed {
  background: var(--danger);
}

.decision-button.missed:hover,
.decision-button.missed.is-selected {
  background: var(--danger-strong);
  box-shadow: 0 12px 24px rgba(184, 74, 74, 0.18);
}

.decision-button.pending {
  background: #747d76;
}

.decision-button.pending:hover,
.decision-button.pending.is-selected {
  background: #59625c;
  box-shadow: 0 12px 24px rgba(89, 98, 92, 0.18);
}

.history-section {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.history-count {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.filter-button {
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fbfcfa;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.15;
  white-space: normal;
}

.filter-button:hover,
.filter-button.is-active {
  border-color: var(--text);
  background: var(--text);
  color: #ffffff;
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.history-date {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.history-goal {
  margin: 0;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #eef1ee;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.done {
  background: #e6f0ea;
  color: var(--accent-strong);
}

.status-pill.missed {
  background: #f4e7e7;
  color: var(--danger-strong);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 720px) {
  .goal-panel {
    padding: 24px;
  }
}

@media (max-width: 540px) {
  .app-shell {
    align-items: stretch;
    padding: 12px;
  }

  .goal-panel {
    min-height: calc(100vh - 24px);
    min-height: calc(100dvh - 24px);
  }

  h1 {
    font-size: 2.7rem;
  }

  label {
    font-size: 1.12rem;
  }

  .stats-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .decision-actions {
    grid-template-columns: 1fr;
  }

  .history-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .status-pill {
    justify-self: start;
  }
}

@media (max-width: 360px) {
  .history-filters {
    grid-template-columns: 1fr;
  }
}
