:root {
  --bg: #f6efe9;
  --card: #fffaf6;
  --text: #3b2f2f;
  --muted: #8a7a74;
  --accent: #c9787f;
  --border: #e6d8cf;
  --danger: #b5483f;
}

* { box-sizing: border-box; }

.entry-text, textarea {
  background: #443631;
  color: #c0a5ee;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}

header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.5rem; font-weight: normal; }

main { max-width: 42rem; margin: 0 auto; padding: 1rem; }

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}

button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.danger { color: var(--danger); border-color: var(--danger); }

#week-summary {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.week-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.week-head h2 { margin: 0; font-size: 1.1rem; font-weight: normal; text-align: center; }
.week-head button { padding: 0.2rem 0.8rem; font-size: 1.2rem; }

#week-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.week-bar { display: flex; align-items: center; gap: 0.5rem; }
.week-bar svg { width: 1.75rem; height: 1.75rem; flex-shrink: 0; }
.week-bar-name { width: 7.5rem; font-size: 0.9rem; }
.week-bar-track { flex: 1; height: 0.9rem; border-radius: 999px; background: var(--bg); overflow: hidden; }
.week-bar-fill { height: 100%; border-radius: 999px; background: var(--mood-color); }
.week-bar-percent { width: 3rem; text-align: right; font-size: 0.9rem; }

#week-empty { margin: 0; text-align: center; color: var(--muted); }

#week-habits {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.5rem;
  font-size: 0.9rem;
}
#week-habits:empty { display: none; }
#week-habits strong { display: block; font-weight: normal; font-size: 0.8rem; opacity: 0.75; }

.habit-meals { --habit-color: #c4ecd0; }
.habit-sleep { --habit-color: #c4e2f5; }
.habit-exercise { --habit-color: #d9cdf5; }
.habit-walk { --habit-color: #fff0a8; }

.check-in, .numbers label, #week-habits li, .entry-habits span {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: var(--habit-color);
}

.check-in { display: flex; flex-direction: column; gap: 0.35rem; }

.meals { display: flex; flex-wrap: wrap; gap: 1rem; }
.meals label { flex-direction: row; align-items: center; gap: 0.35rem; }
.meals input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }

.numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.numbers input {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

.entry-habits { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 0; font-size: 0.85rem; }
.entry-habits span { padding: 0.2rem 0.6rem; border-radius: 999px; }

#calendar {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

#calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.3rem; }
.weekday { text-align: center; font-size: 0.75rem; color: var(--muted); }

.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-height: 4rem;
  padding: 0.25rem 0.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 0.8rem;
}
.day.outside { visibility: hidden; }
.day.today { border: 2px solid var(--accent); }
.day-faces { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; }
.day-faces svg { width: 1.1rem; height: 1.1rem; }
.day-more { font-size: 0.7rem; color: var(--muted); }

#entries { list-style: none; margin: 0; padding: 0; }

.entry {
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.entry-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; }
.entry-text {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  border-radius: 8px;
  white-space: pre-wrap;
}

.mood-tag { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.75rem; }
.mood-part { display: flex; align-items: center; gap: 0.3rem; }
.mood-tag svg { width: 2rem; height: 2rem; }

#strengths { display: flex; flex-direction: column; gap: 0.5rem; }
.strength-row { flex-direction: row; align-items: center; gap: 0.5rem; }
.strength-row svg { width: 2rem; height: 2rem; flex-shrink: 0; }
.strength-name { width: 8rem; }
.strength-row input { flex: 1; accent-color: var(--accent); }
.strength-row output { width: 3rem; text-align: right; }

#empty { text-align: center; color: var(--muted); }

dialog {
  width: min(42rem, 100vw);
  max-height: 100dvh;
  padding: 1.25rem;
  border: none;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}

dialog::backdrop { background: rgb(59 47 47 / 0.4); }

form { display: flex; flex-direction: column; gap: 1rem; }

label { display: flex; flex-direction: column; gap: 0.25rem; }

input[type="date"], textarea {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

input[type="date"] { background: white; color: var(--text); }

textarea { resize: vertical; line-height: 1.5; }
textarea::placeholder { color: #b8aaa4; }

fieldset { border: none; margin: 0; padding: 0; }
legend { padding: 0; margin-bottom: 0.25rem; }
.hint { color: var(--muted); font-size: 0.85rem; }
.error { margin: 0.5rem 0 0; color: var(--danger); }

#moods { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 0.5rem; }
#moods input { position: absolute; opacity: 0; }
#moods span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  height: 100%;
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
}
#moods svg { width: 3rem; height: 3rem; }
#moods input:checked + span { border-color: var(--accent); background: color-mix(in srgb, var(--mood-color) 35%, white); }
#moods input:focus-visible + span { outline: 2px solid var(--accent); }

input[type="range"] { accent-color: var(--accent); }

.actions { display: flex; gap: 0.5rem; }
.spacer { flex: 1; }
