:root {
  --bg: #FBF1E8;
  --card: rgba(255, 255, 255, 0.85);
  --terra: #C76A52;
  --terra-soft: #E9A892;
  --mustard: #E8A24B;
  --mustard-soft: #F2C77A;
  --cream: #F5E5C8;
  --rose: #E27A7A;
  --rose-soft: #F2BABA;
  --text: #4A3528;
  --text-soft: #8B6B5C;
  --border: rgba(199, 106, 82, 0.18);
  --shadow: 0 4px 16px rgba(74, 53, 40, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  background: radial-gradient(ellipse at top, #F5DDC8 0%, #FBF1E8 50%, #F2D5A8 100%) fixed;
  color: var(--text); min-height: 100vh; font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--text-soft); font-size: 13px; line-height: 1.4; }
.err { color: var(--terra); font-size: 13px; margin-top: 8px; min-height: 18px; }
.center { text-align: center; }
input, select, button, textarea {
  font: inherit; color: inherit;
}
input[type="date"], input[type="text"], input[type="password"], input[type="time"], input[type="number"], input[type="url"], select, textarea {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px; outline: none;
  width: 100%; transition: border-color .15s;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { border-color: var(--terra); }
.num { max-width: 110px; }
button {
  cursor: pointer; border: none; border-radius: 12px;
  padding: 12px 18px; font-weight: 600; transition: transform .12s, opacity .12s;
}
button:active { transform: scale(0.96); }
button.primary { background: var(--terra); color: white; }
button.primary:hover { opacity: 0.92; }
button.ghost { background: transparent; color: var(--text-soft); border: 1px solid var(--border); }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); white-space: nowrap; }
.chk input { width: auto; }

/* GATE */
.gate {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, #F5DDC8 0%, #FBF1E8 50%, #F2D5A8 100%);
  z-index: 100;
}
.gate-card {
  max-width: 380px; width: 100%;
  background: var(--card); border-radius: 24px;
  padding: 36px 28px; text-align: center;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.gate-star { font-size: 56px; margin-bottom: 8px; }
.gate-card h1 { font-family: Georgia, serif; font-size: 28px; color: var(--terra); margin-bottom: 8px; }
.gate-card p { margin-bottom: 16px; }
.gate-card input { margin-bottom: 12px; text-align: center; }
.gate-card button { width: 100%; font-size: 18px; }

/* APP */
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px 100px; }
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 6px 16px;
  flex-wrap: wrap; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 26px; }
.brand-name { font-family: Georgia, serif; font-size: 22px; color: var(--terra); font-weight: 700; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs .tab {
  background: rgba(255,255,255,0.5);
  border: 1px solid var(--border);
  padding: 8px 11px;
  font-size: 17px;
  border-radius: 12px;
  color: var(--text-soft);
}
.tabs .tab.active { background: var(--terra); color: white; border-color: var(--terra); }

.tab-panel { display: none; animation: fade .2s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-h { font-family: Georgia, serif; font-size: 24px; color: var(--terra); margin: 4px 4px 14px; }
.sub-h { font-family: Georgia, serif; font-size: 17px; color: var(--terra); margin: 22px 4px 10px; }

/* TODAY */
.today-header { margin-bottom: 18px; padding: 4px 4px; }
.date { font-family: Georgia, serif; font-size: 22px; color: var(--terra); font-weight: 700; text-transform: capitalize; }
.summary { color: var(--text-soft); font-style: italic; margin-top: 4px; font-size: 14px; }
.task-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px; transition: background .2s, transform .12s; cursor: pointer;
}
.task:hover { background: rgba(255,255,255,0.95); }
.task:active { transform: scale(0.99); }
.task.done { background: rgba(232, 162, 75, 0.18); }
.task.done .task-label { text-decoration: line-through; color: var(--text-soft); }
.task.info { cursor: default; }
.task-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--terra-soft); background: transparent; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: white; transition: background .2s, border-color .2s;
  margin-top: 2px;
}
.task.done .task-check { background: var(--terra); border-color: var(--terra); }
.task.done .task-check::after { content: "✓"; }
.task.info .task-check { border-color: transparent; background: transparent; }
.task.info .task-check::after { content: "•"; font-size: 22px; line-height: 1; color: var(--text-soft); }
.task-label { font-size: 15px; line-height: 1.4; color: var(--text); }

/* PLAN */
.plan-section { margin-bottom: 22px; }
.section-label {
  font-size: 11px; letter-spacing: 2.5px;
  color: var(--terra); font-weight: 700;
  margin: 8px 4px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-label .mini { font-size: 16px; padding: 4px 10px; border-radius: 8px; }
.threeday-strip { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.day-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 8px 12px; cursor: pointer; transition: transform .12s, background .2s;
  font-size: 12px; text-align: center;
}
.day-card.today { border-color: var(--terra); border-width: 2px; }
.day-card .day-dow { font-size: 10px; letter-spacing: 1.5px; color: var(--text-soft); text-transform: uppercase; }
.day-card .day-num { font-family: Georgia, serif; font-size: 26px; font-weight: 800; color: var(--terra); margin: 2px 0 0; line-height: 1; }
.day-card .day-mon { font-size: 9px; color: var(--text-soft); letter-spacing: 1.2px; text-transform: uppercase; }
.day-card .day-summary { font-size: 11px; color: var(--text-soft); margin-top: 6px; line-height: 1.3; font-style: italic; }
.day-card .day-progress { margin-top: 8px; height: 4px; background: rgba(232,162,75,0.18); border-radius: 2px; overflow: hidden; }
.day-card .day-progress > div { height: 100%; background: var(--terra); transition: width .3s; }
.month-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  background: var(--card); padding: 8px; border-radius: 14px; border: 1px solid var(--border);
}
.month-grid .mhead { font-size: 10px; color: var(--text-soft); text-align: center; font-weight: 700; padding: 4px 0; letter-spacing: 0.5px; }
.mcell {
  aspect-ratio: 1; border-radius: 10px;
  background: rgba(255,255,255,0.5);
  border: 1px solid transparent;
  padding: 4px; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  cursor: pointer; font-size: 13px; min-height: 42px;
}
.mcell.empty { background: transparent; cursor: default; }
.mcell.today { border-color: var(--terra); border-width: 2px; font-weight: 800; color: var(--terra); }
.mcell.workout { background: rgba(232, 162, 75, 0.18); }
.mcell.crea { background: rgba(226, 122, 122, 0.20); }

/* SETTINGS / CARDS */
.set-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px 18px; margin-bottom: 14px;
}
.set-card h3 { font-family: Georgia, serif; font-size: 17px; color: var(--terra); margin-bottom: 6px; }
.set-card .row { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.set-card .row.col { flex-direction: column; align-items: stretch; }
.set-card .row.col .row { margin-top: 0; }
.set-list { list-style: none; }
.set-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: rgba(255,255,255,0.7); border-radius: 10px; margin-bottom: 6px; font-size: 14px;
}
.set-list li .del { font-size: 12px; color: var(--terra); cursor: pointer; padding: 4px 8px; background: rgba(199,106,82,0.1); border-radius: 8px; border: none; }

/* RECIPES */
.recipe-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.recipe-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; cursor: pointer; transition: transform .12s;
}
.recipe-card:active { transform: scale(0.97); }
.recipe-card .r-img {
  width: 100%; aspect-ratio: 16/10; background-size: cover; background-position: center;
  border-radius: 10px; margin-bottom: 8px; background-color: var(--cream);
  display: flex; align-items: center; justify-content: center; font-size: 36px;
}
.recipe-card .r-title { font-family: Georgia, serif; font-weight: 700; color: var(--terra); font-size: 14px; line-height: 1.2; }
.recipe-card .r-sum { font-size: 11px; color: var(--text-soft); margin-top: 4px; }
.recipe-card .r-heart { color: var(--rose); font-size: 12px; margin-top: 4px; }

/* BUDGET */
.budget-summary {
  background: linear-gradient(135deg, var(--terra) 0%, var(--mustard) 100%);
  color: white; border-radius: 18px;
  padding: 18px 22px; margin-bottom: 16px;
}
.budget-summary .total-label { font-size: 11px; letter-spacing: 2.5px; opacity: 0.85; }
.budget-summary .total-amount { font-family: Georgia, serif; font-size: 32px; font-weight: 800; margin-top: 4px; }
.budget-summary .total-meta { font-size: 12px; opacity: 0.85; margin-top: 4px; }
.budget-summary .total-bar { height: 8px; background: rgba(255,255,255,0.3); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.budget-summary .total-bar > div { height: 100%; background: white; }
.budget-cats { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.cat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px;
}
.cat-card .cat-row { display: flex; justify-content: space-between; align-items: center; }
.cat-card .cat-name { font-size: 13px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; }
.cat-card .cat-amounts { font-size: 11px; color: var(--text-soft); cursor: pointer; }
.cat-card .cat-amounts.editable:hover { color: var(--terra); text-decoration: underline; }
.set-list li .exp-actions { display: flex; gap: 4px; }
.set-list li .edit, .set-list li .del { font-size: 12px; cursor: pointer; padding: 4px 8px; border-radius: 8px; border: none; }
.set-list li .edit { color: var(--mustard); background: rgba(232, 162, 75, 0.15); }
.set-list li .del { color: var(--terra); background: rgba(199,106,82,0.1); }
.cat-card .cat-bar { height: 6px; background: rgba(232,162,75,0.18); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.cat-card .cat-bar > div { height: 100%; background: var(--mustard); }
.cat-card.warn .cat-bar > div { background: var(--terra); }
.cat-card.over .cat-bar > div { background: var(--rose); }
.cat-card.warn .cat-amounts { color: var(--terra); }
.cat-card.over .cat-amounts { color: var(--rose); font-weight: 700; }

/* FITNESS */
.picked { margin-top: 14px; }
.picked .schema-name { font-family: Georgia, serif; font-weight: 700; font-size: 18px; color: var(--terra); margin-bottom: 6px; }
.picked .schema-meta { font-size: 12px; color: var(--text-soft); margin-bottom: 14px; }
.exercise-list { display: flex; flex-direction: column; gap: 10px; }
.exercise {
  background: rgba(255,255,255,0.85);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--border);
}
.ex-img {
  width: 64px; height: 64px;
  background-size: cover; background-position: center;
  background-color: var(--cream);
  border-radius: 10px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.ex-body { flex: 1; min-width: 0; }
.ex-name { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.ex-meta { font-size: 11px; color: var(--text-soft); margin-bottom: 8px; line-height: 1.3; }
.set-row { display: flex; gap: 6px; }
.set-check {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--terra-soft);
  background: transparent;
  font-weight: 700; font-size: 14px;
  color: var(--text-soft);
  transition: all .15s;
  padding: 0;
}
.set-check:active { transform: scale(0.9); }
.set-check.done {
  background: var(--terra); color: white; border-color: var(--terra);
}

/* DAILY FACT */
.daily-fact {
  background: linear-gradient(135deg, rgba(232, 162, 75, 0.15) 0%, rgba(199, 106, 82, 0.10) 100%);
  border: 1px solid rgba(232, 162, 75, 0.35);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.df-label {
  font-size: 10px; letter-spacing: 2px;
  color: var(--mustard); font-weight: 700;
  margin-bottom: 4px;
}
.df-text { font-size: 14px; color: var(--text); line-height: 1.4; font-style: italic; }

/* PROGRESS card */
.progress-card {
  background: var(--card); border-radius: 18px; padding: 16px 18px;
  margin-bottom: 18px; border: 1px solid var(--border); box-shadow: var(--shadow);
}
.prog-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.prog-label { color: var(--terra); font-weight: 700; font-size: 14px; letter-spacing: 0.5px; }
.prog-counter { color: var(--mustard); font-weight: 700; font-size: 14px; }
.prog-bar { height: 10px; background: rgba(232,162,75,0.18); border-radius: 5px; overflow: hidden; }
#prog-fill { height: 100%; background: linear-gradient(90deg, var(--mustard-soft), var(--terra)); border-radius: 5px; transition: width .35s ease; }
.prog-meta { display: flex; justify-content: space-between; margin-top: 12px; font-size: 12px; color: var(--text-soft); }
.prog-meta b { color: var(--text); font-weight: 700; }

/* GARDEN — landscape */
.garden-stats {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; margin-bottom: 14px;
  display: flex; justify-content: space-around; text-align: center;
  font-size: 13px; color: var(--text-soft);
}
.garden-stats b { display: block; color: var(--terra); font-size: 18px; }

.landscape-wrap {
  border-radius: 18px; overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.landscape {
  position: relative;
  width: 100%; height: 380px;
  background: linear-gradient(180deg, #B8D6F0 0%, #DCE9F5 35%, #F4E1B8 70%, #E1B97A 100%);
  overflow: hidden;
}
.landscape .layer { position: absolute; left: 0; right: 0; pointer-events: none; }
.landscape .sky {
  top: 0; height: 35%;
  background: linear-gradient(180deg, #B8D6F0 0%, transparent 100%);
}
.landscape .sky::before, .landscape .sky::after {
  content: "☁️"; position: absolute; font-size: 28px; opacity: 0.85;
}
.landscape .sky::before { top: 18%; left: 18%; }
.landscape .sky::after { top: 38%; right: 22%; font-size: 22px; }
.landscape .mountains {
  bottom: 38%; height: 22%;
  background:
    linear-gradient(135deg, transparent 49%, #8C9D7A 50%, transparent 51%) 20% 100%/30% 100% no-repeat,
    linear-gradient(135deg, transparent 49%, #6B7F5C 50%, transparent 51%) 55% 100%/35% 100% no-repeat,
    linear-gradient(135deg, transparent 49%, #4A6D5F 50%, transparent 51%) 80% 100%/30% 100% no-repeat;
  opacity: 0.7;
}
.landscape .forest {
  bottom: 30%; height: 12%;
  background:
    radial-gradient(ellipse at 15% 100%, #5E7C3A 0%, transparent 30%),
    radial-gradient(ellipse at 35% 100%, #6B8E45 0%, transparent 30%),
    radial-gradient(ellipse at 60% 100%, #4F6E32 0%, transparent 30%),
    radial-gradient(ellipse at 85% 100%, #5E7C3A 0%, transparent 30%);
}
.landscape .water {
  bottom: 0; height: 18%;
  background: linear-gradient(180deg, #4FA0D0 0%, #2F6B98 100%);
  opacity: 0.85;
}
.landscape .water::before {
  content: "～～～"; position: absolute; top: 4px; left: 0; right: 0;
  color: rgba(255,255,255,0.4); font-size: 14px; letter-spacing: 4px; text-align: center;
}
.creatures-overlay { position: absolute; inset: 0; }
.creatures-overlay .c {
  position: absolute; cursor: pointer;
  width: 56px; height: 56px;
  background-size: cover; background-position: center;
  transition: transform .15s;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.creatures-overlay .c:hover { transform: scale(1.1) translateY(-3px); }

.creature-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.creature-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 8px 8px; text-align: center;
  cursor: pointer; transition: background .2s, transform .12s;
}
.creature-card:active { transform: scale(0.97); }
.creature-card.locked { opacity: 0.4; filter: grayscale(0.8); cursor: default; }
.creature-card .cc-img {
  width: 100%; aspect-ratio: 1;
  background-size: cover; background-position: center;
  border-radius: 10px; margin-bottom: 4px;
  background-color: var(--cream);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
}
.creature-card.locked .cc-img::after { content: "🔒"; font-size: 22px; }
.creature-card .cc-name { font-size: 11px; color: var(--text); font-weight: 600; line-height: 1.2; }
.creature-card .cc-rarity { font-size: 10px; color: var(--text-soft); margin-top: 2px; }
.cc-rarity.rare { color: var(--mustard); font-weight: 700; }
.cc-rarity.epic { color: var(--terra); font-weight: 700; }

/* CELEBRATE */
.celebrate {
  position: fixed; inset: 0;
  background: rgba(74, 53, 40, 0.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 200;
}
.celebrate-inner {
  background: var(--bg); border-radius: 24px; padding: 32px 28px;
  text-align: center; max-width: 320px;
  border: 2px solid var(--terra-soft);
}
.celebrate-burst { font-size: 60px; }
.celebrate-creature {
  width: 140px; height: 140px; margin: 12px auto;
  background-size: cover; background-position: center;
  border-radius: 24px; background-color: var(--cream);
  display: flex; align-items: center; justify-content: center; font-size: 72px;
}
.celebrate-inner h2 { font-family: Georgia, serif; color: var(--terra); font-size: 24px; }
.celebrate-inner p { color: var(--text); font-style: italic; margin: 6px 0; }

/* MODAL */
.modal {
  position: fixed; inset: 0;
  background: rgba(74, 53, 40, 0.55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 150;
}
.modal-card {
  background: var(--bg); border-radius: 22px; padding: 24px;
  max-width: 380px; width: 100%; max-height: 88vh; overflow-y: auto;
  position: relative; border: 1px solid var(--border);
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; color: var(--text-soft);
  padding: 6px 10px; border-radius: 999px;
}
.modal-creature-img {
  width: 100%; aspect-ratio: 1; border-radius: 18px;
  background-color: var(--cream); background-size: cover; background-position: center;
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 64px;
}
.modal h3 { font-family: Georgia, serif; color: var(--terra); font-size: 22px; margin-bottom: 4px; }
.modal .modal-meta { color: var(--text-soft); font-style: italic; margin-bottom: 14px; font-size: 13px; }
.modal .fun-fact {
  margin-top: 14px;
  background: rgba(232, 162, 75, 0.2);
  padding: 12px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.45; color: var(--text); font-style: italic;
}
.modal .fun-fact::before { content: "✨ "; }

@media (max-width: 480px) {
  #app { padding: 12px 12px 80px; }
  .recipe-list { grid-template-columns: 1fr; }
  .creature-grid { grid-template-columns: repeat(2, 1fr); }
  .landscape { height: 280px; }
  .creatures-overlay .c { width: 44px; height: 44px; }
}
