:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8b919e;
  --accent: #4ade80;
  --accent-dim: #2f7a4f;
  --danger: #f87171;
  --radius: 16px;
  --nav-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }

/* ---------- Onboarding ---------- */
.onboarding {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.onboarding-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
}
.onboarding-card h1 { margin: 0 0 6px; font-size: 1.6rem; }
.onboarding-card label {
  display: block;
  text-align: left;
  margin: 18px 0 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- App layout ---------- */
#app { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.view { display: none; padding: 16px 16px 24px; }
.view.active { display: block; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 2px 18px;
  padding-top: env(safe-area-inset-top);
}
.topbar h1 { margin: 0; font-size: 1.4rem; }

/* ---------- Counter ---------- */
.counter-wrap {
  text-align: center;
  padding: 36px 12px 28px;
}
.counter-number {
  font-size: 5.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -2px;
}
.counter-label { font-size: 1.2rem; margin-top: 8px; }
.counter-since { margin-top: 14px; font-size: 0.9rem; }

/* ---------- Buttons ---------- */
button { font-family: inherit; cursor: pointer; border: none; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #06120b;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 16px;
  border-radius: var(--radius);
  margin-top: 12px;
}
.btn-primary.big { font-size: 1.15rem; padding: 18px; }
.btn-primary:active { background: var(--accent-dim); }

.btn-secondary {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
  padding: 15px;
  border-radius: var(--radius);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  padding: 8px 10px;
  border-radius: 10px;
}
.btn-ghost:active { background: var(--surface-2); }

.btn-danger {
  width: 100%;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  font-weight: 600;
  padding: 14px;
  border-radius: var(--radius);
}
.btn-danger:active { background: rgba(248,113,113,0.12); }

/* ---------- Inputs ---------- */
input[type="date"],
input[type="text"],
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  padding: 14px;
  border-radius: 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent-dim); }
textarea { resize: vertical; }

/* ---------- Journal ---------- */
.entries-list { display: flex; flex-direction: column; gap: 12px; }
.entry-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.entry-card .entry-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.entry-date { font-size: 0.82rem; color: var(--muted); }
.entry-mood { font-size: 1.3rem; }
.entry-thoughts { white-space: pre-wrap; word-break: break-word; }
.entry-trigger {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--muted);
}
.entry-trigger b { color: var(--text); font-weight: 600; }
.empty { text-align: center; padding: 60px 20px; }

/* ---------- Settings ---------- */
.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.settings-block label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}
.settings-block .small { margin: 8px 0 0; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
}
.nav-btn {
  flex: 1;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.72rem;
}
.nav-btn .nav-ico { font-size: 1.25rem; line-height: 1; }
.nav-btn.active { color: var(--accent); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 92vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head h2 { margin: 0; font-size: 1.25rem; }
.modal-datetime { font-size: 0.82rem; margin: 4px 0 14px; }
.modal-card label {
  display: block;
  margin: 14px 0 6px;
  font-size: 0.9rem;
  color: var(--muted);
}
.mood-row { display: flex; gap: 8px; }
.mood-btn {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1.5rem;
  padding: 10px 0;
  filter: grayscale(0.6) opacity(0.6);
}
.mood-btn.selected {
  border-color: var(--accent);
  filter: none;
  background: rgba(74,222,128,0.10);
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.modal-actions .btn-primary,
.modal-actions .btn-danger { margin-top: 0; }
.modal-actions .btn-danger { flex: 0 0 38%; }
