:root {
  --green: #2e9e5b;
  --orange: #e0973a;
  --red: #d9483d;
  --bg: #f5f4f0;
  --card-bg: #ffffff;
  --text: #262421;
  --muted: #7a766f;
  --accent: #2e7d5e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1rem; color: var(--muted); margin: 24px 0 10px; }

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 6px 0;
}

/* login */
.login-box { padding-top: 12vh; text-align: center; }
.subtitle { color: var(--muted); margin-bottom: 20px; }
.user-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.user-list button {
  padding: 14px;
  font-size: 1.05rem;
  border-radius: 12px;
  border: 1px solid #ddd8ce;
  background: var(--card-bg);
  cursor: pointer;
}
.new-user-form { display: flex; gap: 8px; }
.new-user-form input {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #ddd8ce;
  font-size: 1rem;
}
.new-user-form button {
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

/* main */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.week-range { color: var(--muted); font-size: 0.85rem; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.category-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid #ece8de;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.category-card .icon { font-size: 1.6rem; }
.category-card .label { font-weight: 600; font-size: 0.95rem; line-height: 1.2; }
.category-card .count { font-size: 0.85rem; color: var(--muted); }

.bar-track {
  height: 8px;
  border-radius: 4px;
  background: #ece8de;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 4px; }
.status-green .bar-fill, .status-green .count-dot { background: var(--green); }
.status-orange .bar-fill, .status-orange .count-dot { background: var(--orange); }
.status-red .bar-fill, .status-red .count-dot { background: var(--red); }

.card-add {
  align-self: flex-end;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

/* detail */
.detail-header { margin-bottom: 16px; }
.detail-header h1 { margin-top: 6px; }

.detail-status {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid #ece8de;
}
.status-row { display: flex; justify-content: space-between; align-items: center; }
.status-count { font-size: 1.8rem; font-weight: 700; }
.target-editor { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.stepper {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid #ddd8ce;
  background: white;
  cursor: pointer;
  font-size: 1rem;
}
.detail-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.add-button {
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-row { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.history-row .h-label { width: 90px; color: var(--muted); flex-shrink: 0; }
.history-row .bar-track { flex: 1; }
.history-row .h-count { width: 46px; text-align: right; flex-shrink: 0; }
.history-row.current .h-label { color: var(--text); font-weight: 600; }

.note-section textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #ddd8ce;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}
.note-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.note-meta { color: var(--muted); font-size: 0.8rem; }
