:root {
  --bg: #fff6e5;
  --accent: #ffb703;
  --accent-dark: #e69100;
  --text: #3a2e1f;
  --muted: #8a7a63;
  --card: #ffffff;
  --danger: #d9534f;
  --good: #2e8b57;
  --nav-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* Nav lives at the top, icon-only and large so it's an easy thumb/eye
   target; order in the HTML is Settings, Home, Stats left-to-right. */
nav.tabbar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-bottom: 1px solid #eadfc8;
  background: var(--card);
  padding: calc(6px + env(safe-area-inset-top)) 0 6px;
  flex: 0 0 auto;
  height: var(--nav-height);
}

nav.tabbar a {
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
  padding: 8px 20px;
  border-radius: 12px;
  opacity: 0.55;
}

nav.tabbar a.active {
  opacity: 1;
  background: rgba(255, 183, 3, 0.15);
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  overflow-y: auto;
}

/* ---- Home page: big button anchored near the bottom, full screen used ---- */

main.home-main {
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
  justify-content: flex-start;
}

.top-copy {
  flex: 0 0 auto;
  padding-top: 6vh;
}

.title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  text-align: center;
}

.subtitle {
  color: var(--muted);
  text-align: center;
}

.home-spacer {
  flex: 1 1 auto;
}

.tap-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 0 0 auto;
}

#happy-btn {
  font-size: 26px;
  font-weight: 700;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  width: 100%;
  max-width: 360px;
  padding: 34px 24px;
  box-shadow: 0 10px 26px rgba(255, 183, 3, 0.45);
  cursor: pointer;
  transition: transform 0.08s ease;
  user-select: none;
}

#happy-btn:active {
  transform: scale(0.95);
}

.floating-emoji {
  position: absolute;
  font-size: 32px;
  pointer-events: none;
  animation: float-away 1100ms ease-out forwards;
  left: 50%;
  top: 0;
}

@keyframes float-away {
  0% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift, 0px)), -140px) scale(1.3); }
}

.count-line {
  margin-top: 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  flex: 0 0 auto;
}

.status-pill {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  padding: 4px;
  color: white;
  background: var(--muted);
  transform: translateY(-100%);
  transition: transform 0.2s ease;
  z-index: 20;
}

.status-pill.visible { transform: translateY(0); }
.status-pill.offline { background: var(--danger); }
.status-pill.syncing { background: var(--accent-dark); }
.status-pill.update { background: var(--good); cursor: pointer; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  margin-bottom: 16px;
}

h1.page-title {
  font-size: 20px;
  margin: 12px 0 20px;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn.secondary {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-email {
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 13px; }

/* ---- Stats page: day tabs (equal width, swipeable) + time-vertical chart ---- */

main.stats-main {
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  align-items: stretch;
  overflow: hidden;
}

.day-tabs {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
  flex: 0 0 auto;
  margin-bottom: 10px;
  touch-action: pan-y;
}

.day-tabs button {
  border: 1px solid #eadfc8;
  background: var(--card);
  border-radius: 10px;
  padding: 8px 2px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.day-tabs button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  touch-action: pan-y;
}

canvas#chart {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--card);
  border-radius: 12px;
}

.bucket-tooltip {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--text);
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  z-index: 5;
}

.total-line {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  flex: 0 0 auto;
}
