/* Quest Ledger — calm adventure theme. Light-first, mobile-first. */
:root {
  --bg: #f6f4ee;
  --card: #ffffff;
  --ink: #22301f;
  --ink-soft: #5c6b58;
  --line: #e3dfd2;
  --brand: #2f6f4f;
  --brand-dark: #245a3f;
  --accent: #ffd166;
  --accent-ink: #5c4400;
  --danger: #b3402f;
  --ok: #2f6f4f;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(34, 48, 31, 0.08), 0 4px 14px rgba(34, 48, 31, 0.06);
  --tap: 44px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }
#view {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
  outline: none;
}

h1 { font-size: 1.45rem; margin: 4px 0 12px; }
h2 { font-size: 1.1rem; margin: 22px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 10px 0;
}

button, .btn, select, input[type="text"], input[type="email"], input[type="date"],
input[type="password"], input[type="number"], textarea {
  font: inherit;
  min-height: var(--tap);
  border-radius: 10px;
}
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 4px; color: var(--ink-soft); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}
button:active, .btn:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--danger); border-color: var(--danger); background: #fff; }
button.ghost { border-color: transparent; background: transparent; }
button.big { width: 100%; min-height: 56px; font-size: 1.05rem; border-radius: 14px; }
button[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Bottom tab bar — child destinations. */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 2px 10px;
  min-height: 58px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
}
.tabbar a .ico { font-size: 1.25rem; }
.tabbar a.active { color: var(--brand); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: var(--tap);
  font-weight: 600;
  cursor: pointer;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Progress */
.progress { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.progress.warn > i { background: var(--accent); }
.progress.done > i { background: var(--ok); }

.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
.badge-pill { background: #fff7e0; border: 1px solid #f0dfa8; border-radius: 999px; padding: 4px 10px; font-size: 0.85rem; font-weight: 600; }

/* Task cards */
.task { border-left: 4px solid var(--line); }
.task .track-tag { font-size: 0.78rem; font-weight: 700; color: var(--ink-soft); }
.task.done { border-left-color: var(--ok); opacity: 0.85; }
.task.trying { border-left-color: var(--accent); }
.task.required .req-flag { color: var(--danger); font-size: 0.8rem; font-weight: 700; }
.task .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Week strip */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week .day { text-align: center; padding: 8px 2px; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-size: 0.78rem; }
.week .day .n { font-size: 0.95rem; font-weight: 700; }
.week .day.hit { background: #e7f2ea; border-color: var(--brand); }
.week .day.today { outline: 2px solid var(--accent); }

/* Uploads */
.upl { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.upl .bar { flex: 1; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: #eee; }
.thumb.big { width: 100%; height: auto; max-height: 60dvh; }

/* Toast */
#toast {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-weight: 600; font-size: 0.9rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw; text-align: center;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(20, 28, 18, 0.45); display: grid; place-items: end center; z-index: 40; }
.modal { background: var(--card); width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px; }
@media (min-width: 640px) { .modal-back { place-items: center; } .modal { border-radius: 18px; } }

/* Chooser */
.chooser-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.chooser-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px; }
.chooser-card .ava { font-size: 2rem; }

/* Tables */
table.simple { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.simple th, table.simple td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.simple th { color: var(--ink-soft); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* Celebration */
.celebrate { animation: pop 0.5s ease; }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* Save state pill */
.save-state { font-size: 0.8rem; font-weight: 700; }
.save-state.draft { color: var(--accent-ink); }
.save-state.saved { color: var(--ok); }
.save-state.error { color: var(--danger); }

/* Desktop sidebar */
@media (min-width: 820px) {
  #app { flex-direction: row; }
  .tabbar {
    position: sticky; top: 0;
    flex-direction: column;
    width: 200px; height: 100dvh;
    border-top: 0; border-right: 1px solid var(--line);
    padding: 18px 10px;
    order: -1;
    flex: none;
  }
  .tabbar a { flex-direction: row; gap: 10px; min-height: var(--tap); padding: 10px 12px; font-size: 0.9rem; border-radius: 10px; }
  .tabbar a.active { background: #e7f2ea; }
  #view { padding-bottom: 40px; }
}

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