/* Choupinou Care Center — warm, calm, minimal */

:root {
  --bg:        #f6efe1;
  --bg-soft:   #fbf6ea;
  --ink:       #3a2f28;
  --ink-soft:  #6b5b50;
  --muted:     #8c7e72;
  --line:      #e7dcc8;
  --peach:     #e8b298;
  --peach-deep:#c87a5c;
  --sage:      #b7c9a8;
  --sage-deep: #6a8765;
  --clay:      #d9a48a;
  --clay-deep: #a86b50;
  --warn:      #c47a4a;
  --shadow:    0 1px 0 rgba(58,47,40,.04), 0 6px 24px -10px rgba(58,47,40,.18);
  --radius:    18px;
  --radius-sm: 12px;
  --font:      -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #1d1814;
    --bg-soft:  #251e19;
    --ink:      #f0e6d6;
    --ink-soft: #cdbfae;
    --muted:    #9d8e7e;
    --line:     #3a2f26;
    --shadow:   0 1px 0 rgba(0,0,0,.3), 0 8px 28px -10px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; }

/* ---------- Login ---------- */
body.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% 0%, #fbe9d3 0%, var(--bg) 60%);
}
.auth-card {
  width: min(380px, 92vw);
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-card .logo { margin-bottom: 8px; }
.auth-card h1 { margin: 4px 0 0; font-size: 22px; font-weight: 600; letter-spacing: .2px; }
.auth-card .tagline { color: var(--muted); margin: 6px 0 24px; font-size: 14px; }
.auth-card form { display: grid; gap: 14px; text-align: left; }
.auth-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.auth-card input {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 16px;
}
@media (prefers-color-scheme: dark) {
  .auth-card input { background: #2c241d; }
}
.auth-card button {
  margin-top: 4px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 0;
  background: var(--peach-deep);
  color: #fff;
  font-weight: 600;
  letter-spacing: .2px;
}
.auth-card button:disabled { opacity: .6; }
.error { color: var(--clay-deep); font-size: 14px; margin: 0; }

/* ---------- App chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.tabbar {
  position: sticky; top: 57px; z-index: 4;
  display: flex; gap: 6px;
  overflow-x: auto;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.tab[aria-selected="true"] {
  background: var(--peach);
  color: #4a2418;
}
.tab:hover { color: var(--ink); }

main#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 18px 80px;
}
.view-header h2 { margin: 6px 0 2px; font-size: 24px; font-weight: 600; }
.view-header .muted { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: -8px 0 10px; }
.section-title { margin: 24px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card.soft p:first-child { margin-top: 0; }
.card.soft p:last-child  { margin-bottom: 0; }
.card.warm { background: #fbeadc; border-color: #f1d4bd; }
.card.sage { background: #ecf2e2; border-color: #d4e1c2; }
.card.clay { background: #f5e0d3; border-color: #ecc6b1; }
@media (prefers-color-scheme: dark) {
  .card.warm { background: #3a261c; border-color: #5a3b2c; }
  .card.sage { background: #283323; border-color: #3d4d34; }
  .card.clay { background: #3a261d; border-color: #5a382a; }
}

.numbered { padding-left: 1.2em; }
.numbered li { margin: 6px 0; }

/* ---------- Today / routines ---------- */
.slot {
  margin-bottom: 18px;
}
.slot h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--muted); margin: 0 0 8px 4px; font-weight: 600;
}
.slot-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.routine {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.routine.done { opacity: .55; }
.routine .who {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--line); color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .08em;
}
.routine .label { flex: 1; }
.routine input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 999px;
  border: 1.5px solid var(--peach-deep);
  display: grid; place-items: center;
  background: transparent;
}
.routine input[type="checkbox"]:checked {
  background: var(--peach-deep);
}
.routine input[type="checkbox"]:checked::after {
  content: ""; width: 10px; height: 6px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px,-1px);
}
.routine .del {
  background: transparent; border: 0; color: var(--muted); font-size: 18px; padding: 4px 8px;
}

/* ---------- Inline forms / add ---------- */
.add { margin-top: 10px; }
.add > summary {
  list-style: none; cursor: pointer;
  color: var(--peach-deep); font-weight: 600; font-size: 14px;
  padding: 8px 4px;
}
.add > summary::-webkit-details-marker { display: none; }
.add > summary::before { content: "+ "; }
.add[open] > summary::before { content: "− "; }
.inline-form {
  display: flex; gap: 8px; flex-wrap: wrap;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 6px;
}
.inline-form.column { flex-direction: column; }
.inline-form input, .inline-form select, .inline-form textarea {
  flex: 1; min-width: 0;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
@media (prefers-color-scheme: dark) {
  .inline-form input, .inline-form select, .inline-form textarea { background: #2c241d; }
}
.inline-form button {
  padding: 10px 16px; border: 0; border-radius: 10px;
  background: var(--peach-deep); color: #fff; font-weight: 600;
}

/* ---------- Mood ---------- */
.mood-loggers { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 600px) { .mood-loggers { grid-template-columns: 1fr; } }
.mood-card h3 { margin: 0 0 10px; font-size: 16px; }
.mood-buttons { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.mood-buttons button {
  flex: 1 1 0; min-width: 0;
  padding: 12px 0; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; font-size: 20px;
}
.mood-buttons button:hover { background: #fff; }
@media (prefers-color-scheme: dark) { .mood-buttons button:hover { background: #2c241d; } }
.mood-note {
  width: 100%;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff;
}
@media (prefers-color-scheme: dark) { .mood-note { background: #2c241d; } }

.mood-history { display: grid; gap: 14px; }
.mood-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: center; }
.mood-row .who { font-size: 13px; color: var(--ink-soft); }
.mood-track { display: flex; gap: 4px; }
.mood-cell {
  flex: 1 1 0; height: 28px; border-radius: 8px;
  background: var(--line);
  display: grid; place-items: center;
  font-size: 13px; color: var(--ink-soft);
}
.mood-cell.s1 { background: #d8a18b; color: #4a2418; }
.mood-cell.s2 { background: #e7c2a3; color: #4a2418; }
.mood-cell.s3 { background: #e8d6a8; color: #4a2418; }
.mood-cell.s4 { background: #c8d6a8; color: #2a3a1f; }
.mood-cell.s5 { background: #a8c89b; color: #2a3a1f; }

/* ---------- Generic card lists ---------- */
.card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card-list li {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: var(--shadow);
}
.card-list li.done { opacity: .55; }
.card-list .grow { flex: 1; min-width: 0; }
.card-list .title { font-weight: 600; }
.card-list .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-list .actions { display: flex; gap: 6px; }
.card-list .actions button {
  background: transparent; border: 1px solid var(--line);
  color: var(--ink-soft); border-radius: 999px; padding: 4px 10px; font-size: 12px;
}
.card-list a { color: var(--peach-deep); text-decoration: none; }
.card-list a:hover { text-decoration: underline; }

/* ---------- Editable lists ---------- */
.editable-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.editable-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.editable-list li .grow { flex: 1; }
.editable-list li button {
  background: transparent; border: 0; color: var(--muted); font-size: 18px;
}

/* ---------- Scope two-column ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Reflection ---------- */
.month-picker { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.month-picker input {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff;
}
@media (prefers-color-scheme: dark) { .month-picker input { background: #2c241d; } }
#reflect-text {
  width: 100%; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
  resize: vertical; min-height: 160px;
}
@media (prefers-color-scheme: dark) { #reflect-text { background: #2c241d; } }
.row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
#reflect-save {
  padding: 10px 18px; border: 0; border-radius: 999px;
  background: var(--sage-deep); color: #fff; font-weight: 600;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg-soft);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Misc ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Topbar actions + account dialog ---------- */
.topbar-actions { display: flex; gap: 8px; }

.account-dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  max-width: 420px;
  width: calc(100% - 32px);
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.account-dialog::backdrop {
  background: rgba(40, 30, 20, 0.35);
  backdrop-filter: blur(2px);
}
.account-dialog h2 { margin: 0 0 4px; font-size: 20px; }
.account-dialog form { display: flex; flex-direction: column; gap: 12px; }
.account-dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.account-dialog input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft, #fff);
  color: var(--ink);
}
.account-dialog .row.end { justify-content: flex-end; gap: 8px; }
.account-dialog .hint { font-size: 13px; color: var(--muted); margin: 0; }
