/* Urge Log — mobile-first, card-based, sans-serif only. */

:root {
  --bg: #F1EFE9;
  --ink: #1B1A17;
  --ink-55: rgba(27, 26, 23, 0.55);
  --ink-15: rgba(27, 26, 23, 0.15);
  --surface: #FBFAF7;
  --greige: #E5E1D8;
  --mustard: #E5B94E;
  --rose: #D8A49C;
  --sage: #A9C29B;
  --teal: #93BFB2;
  --lilac: #C0B2DC;
  --cream: #EFE6CF;
  --dark: #1E1D1A;
  --radius: 22px;
  --int-1: #B9CDA9;
  --int-2: #DFCC7F;
  --int-3: #E5B94E;
  --int-4: #D99167;
  --int-5: #C26A57;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(120px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

input, textarea {
  font-family: inherit;
  font-size: 16px;
  color: var(--ink);
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.offline-dot {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  background: var(--int-5);
  border-radius: 999px;
  padding: 4px 10px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--greige);
}

.label-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.label-chip--outline {
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
}

/* ---------- segmented control ---------- */

.seg-control {
  display: flex;
  background: var(--greige);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}

.seg {
  flex: 1;
  height: 44px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-55);
}

.seg.is-active { background: var(--dark); color: #fff; }

/* ---------- cards ---------- */

.card {
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  background: var(--surface);
}

.card .label-chip { display: block; margin-bottom: 12px; }

.card--greige { background: var(--greige); }
.card--mustard { background: var(--mustard); }
.card--sage { background: var(--sage); }
.card--dark { background: var(--dark); color: #fff; }
.card--dark .label-chip { color: #fff; }
.card--cream { background: var(--cream); }

.day-color-0 { background: var(--lilac); }
.day-color-1 { background: var(--rose); }
.day-color-2 { background: var(--teal); }
.day-color-3 { background: var(--sage); }
.day-color-4 { background: var(--mustard); }
.day-color-5 { background: var(--cream); }
.day-color-6 { background: var(--greige); }

/* ---------- oversized numerals ---------- */

.big-num {
  font-size: clamp(56px, 19vw, 86px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.92;
  white-space: nowrap;
}

.big-num--sub {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-55);
  letter-spacing: 0;
}

.card--dark .big-num--sub { color: rgba(255, 255, 255, 0.6); }

.mid-num {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  min-width: 0;
  overflow-wrap: anywhere; /* long redirect names ("Prayer/reflection") must wrap, not overflow */
}

/* ---------- today header card ---------- */

.day-hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.day-hero-date {
  text-align: right;
  white-space: nowrap;
}

.day-hero-date strong {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.onboard-date {
  font-size: 17px;
  font-weight: 700;
  margin-top: 12px;
}

/* onboarding mini-form */
.onboard-row { display: flex; gap: 10px; margin-top: 14px; }
.onboard-row input[type="date"] {
  flex: 1;
  height: 52px;
  border: 1.5px solid var(--ink-15);
  border-radius: 14px;
  padding: 0 14px;
  background: #fff;
}
.onboard-row button {
  height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  background: var(--dark);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- entry rows ---------- */

.entry-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 0;
  border-bottom: 1px solid var(--ink-15);
  min-height: 52px;
}

.entry-row:last-child { border-bottom: none; }

.entry-time {
  font-size: 14px;
  font-weight: 700;
  min-width: 52px;
  flex-shrink: 0;
}

.entry-type {
  font-size: 15px;
  font-weight: 600;
  text-transform: capitalize;
  flex: 1;
  min-width: 0; /* let the text column shrink so chips never overflow the card */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-note {
  display: block;
  text-transform: none;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-55);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.int-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 6px 11px;
  color: var(--ink);
  flex-shrink: 0;
  white-space: nowrap;
}

.int-1 { background: var(--int-1); }
.int-2 { background: var(--int-2); }
.int-3 { background: var(--int-3); }
.int-4 { background: var(--int-4); }
.int-5 { background: var(--int-5); color: #fff; }

.going-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 5px 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

.pending-tag { opacity: 0.5; font-size: 11px; font-weight: 700; }

.empty-note {
  color: var(--ink-55);
  font-size: 15px;
  padding: 6px 0;
}

/* ---------- history ---------- */

.day-card { cursor: pointer; }

.day-card-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.day-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  text-align: right;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-55);
  line-height: 1.4;
  white-space: nowrap;
}

.count-pill {
  display: inline-block;
  background: var(--dark);
  color: #fff;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 14px;
  font-weight: 700;
}

.day-card--future { opacity: 0.45; }

.day-entries { margin-top: 8px; }

/* ---------- stats ---------- */

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  margin-top: 8px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}

.bar-val { font-size: 13px; font-weight: 800; }

.bar {
  width: 100%;
  border-radius: 10px;
  background: rgba(27, 26, 23, 0.28);
  min-height: 6px;
}

.bar--peak { background: var(--dark); }

.bar-day {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-55);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}

.stat-name { flex: 1; font-size: 15px; font-weight: 600; }

.stat-pct { font-size: 15px; font-weight: 800; min-width: 44px; text-align: right; }

.stat-bar-track {
  flex: 2;
  height: 8px;
  border-radius: 999px;
  background: var(--ink-15);
  overflow: hidden;
}

.stat-bar-fill { height: 100%; border-radius: 999px; background: var(--dark); }

.stats-hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.int-day-row { display: flex; gap: 8px; margin-top: 6px; }

.int-day {
  flex: 1;
  border-radius: 12px;
  padding: 10px 0 8px;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
}

.int-day small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-55);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- FAB ---------- */

.fab {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  height: 64px;
  padding: 0 34px;
  border-radius: 999px;
  background: var(--dark);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(27, 26, 23, 0.35);
  z-index: 40;
}

.fab:active { transform: translateX(-50%) scale(0.97); }

.fab-plus { font-size: 28px; font-weight: 600; line-height: 1; margin-top: -2px; }

/* ---------- bottom sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 26, 23, 0.4);
  z-index: 50;
  opacity: 1;
  transition: opacity 0.2s;
}

.backdrop[hidden] { display: none; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 480px;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 90dvh;
  overflow-y: auto;
  transform: translateY(103%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0.22, 1);
  z-index: 60;
}

.sheet.is-open { transform: translateY(0); }

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--ink-15);
  margin: 4px auto 14px;
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sheet-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }

.sheet-time { font-size: 14px; font-weight: 600; color: var(--ink-55); }

.field { margin-bottom: 18px; }

.field > .label-chip { display: block; margin-bottom: 9px; color: var(--ink-55); }

/* type */
.type-row { display: flex; gap: 10px; }

.type-btn {
  flex: 1;
  height: 58px;
  border-radius: 16px;
  border: 1.5px solid var(--ink-15);
  background: #fff;
  font-size: 17px;
  font-weight: 700;
}

.type-btn.is-selected { background: var(--dark); border-color: var(--dark); color: #fff; }

/* intensity */
.intensity-row { display: flex; gap: 6px; }

.intensity-seg {
  flex: 1;
  height: 52px;
  border-radius: 12px;
  border: 3px solid transparent;
}

.intensity-seg.is-selected { border-color: var(--dark); }

.intensity-labels { display: flex; gap: 6px; margin-top: 5px; }

.intensity-labels span {
  flex: 1;
  text-align: center;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-55);
}

.intensity-labels span.is-selected { color: var(--ink); font-weight: 800; }

/* chips */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  height: 46px;
  padding: 0 17px;
  border-radius: 999px;
  border: 1.5px solid var(--ink-15);
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.chip.is-selected { background: var(--dark); border-color: var(--dark); color: #fff; }

.other-input {
  width: 100%;
  height: 50px;
  margin-top: 10px;
  border: 1.5px solid var(--ink-15);
  border-radius: 14px;
  padding: 0 14px;
  background: #fff;
}

/* passed */
.passed-row { display: flex; gap: 10px; }

.passed-btn {
  flex: 1;
  height: 56px;
  border-radius: 16px;
  border: 1.5px solid var(--ink-15);
  background: #fff;
  font-size: 16px;
  font-weight: 700;
}

.passed-btn.is-selected { border-color: var(--dark); border-width: 3px; }
.passed-yes.is-selected { background: var(--sage); }
.passed-going.is-selected { background: var(--cream); }

/* note */
.note-toggle {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-55);
  padding: 10px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.note-input {
  width: 100%;
  border: 1.5px solid var(--ink-15);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  resize: vertical;
}

/* submit */
.submit-btn {
  width: 100%;
  height: 60px;
  border-radius: 18px;
  background: var(--dark);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  margin-top: 4px;
}

.submit-btn:active { transform: scale(0.98); }

.ghost-btn {
  width: 100%;
  height: 54px;
  border-radius: 18px;
  border: 1.5px solid var(--ink);
  font-size: 16px;
  font-weight: 700;
  margin-top: 10px;
}

.settings-input {
  width: 100%;
  height: 52px;
  border: 1.5px solid var(--ink-15);
  border-radius: 14px;
  padding: 0 14px;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
}

/* very narrow screens (iPhone SE class): tighten entry rows so the
   type label always keeps some width next to the status chips */
@media (max-width: 360px) {
  .entry-row { gap: 8px; }
  .entry-time { min-width: 42px; font-size: 13px; }
  .entry-type { min-width: 40px; }
  .int-chip { padding: 5px 8px; font-size: 10px; letter-spacing: 0.03em; }
  .going-tag { padding: 4px 7px; font-size: 10px; letter-spacing: 0.03em; }
}

/* toast */
.toast {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  padding: 11px 20px;
  z-index: 70;
  animation: toast-in 0.25s, toast-out 0.3s 1.9s forwards;
  white-space: nowrap;
}

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 8px); } }
