@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("assets/fonts/jakarta.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --bg-top: #243044;
  --bg-mid: #1C2436;
  --bg-bottom: #171422;
  --glass: #2A3850;
  --glass-border: #6E7C9A;
  --border-45: rgba(110, 124, 154, .45);
  --border-60: rgba(110, 124, 154, .6);
  --text: #F4F2EE;
  --text2: #B7C0CE;
  --chip: #31445F;
  --nav: rgba(22, 20, 31, .96);
  --nav-ind: rgba(62, 79, 114, .9);
  --search: #24344C;
  --primary: #647FA3;
  --danger: #B86662;
  --sheet: #2A3550;
  --work: #668DB7;
  --rest: #87A98D;
  --people: #D98274;
  --thoughts: #9182B5;
  --moments: #D5A45E;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg-bottom);
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
[hidden] { display: none !important; }
svg.i { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }

#app {
  position: relative;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--bg-top), var(--bg-mid) 50%, var(--bg-bottom));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (min-width: 561px) { #app { box-shadow: 0 0 0 1px rgba(110,124,154,.25), 0 20px 60px rgba(0,0,0,.4); } body { background: #0f0d17; } }

#tabs { flex: 1; position: relative; min-height: 0; }
.tab { position: absolute; inset: 0; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pb24 { padding-bottom: 24px; }
.pb88 { padding-bottom: 96px; }

/* Bottom navigation */
#nav {
  display: flex; height: calc(68px + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--nav); flex: none;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--text2); font-size: 12px; font-weight: 500; min-width: 0;
}
.nav-item .pill { width: 56px; height: 30px; border-radius: 16px; display: grid; place-items: center; transition: background .2s; }
.nav-item svg.i { width: 22px; height: 22px; }
.nav-item[aria-selected="true"] { color: var(--text); }
.nav-item[aria-selected="true"] .pill { background: var(--nav-ind); }

/* Header */
.hdr { display: flex; align-items: flex-start; padding: 20px 12px 4px 20px; }
.hdr-text { flex: 1; min-width: 0; }
.hdr h1 { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: -.3px; line-height: 1.25; }
.hdr p { margin: 6px 0 0; color: var(--text2); line-height: 1.35; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text); flex: none; }
.icon-btn:hover { background: rgba(255,255,255,.06); }
.icon-btn:disabled { color: rgba(183,192,206,.4); cursor: default; background: none; }

/* Glass card */
.glass {
  display: block; width: 100%; text-align: left;
  border-radius: 24px; padding: 16px;
  background: linear-gradient(135deg, #2E4664, #2A3C56 50%, #3A3458);
  border: 1px solid var(--border-45);
}
button.glass { transition: filter .15s; }
button.glass:hover { filter: brightness(1.08); }
button.glass:active { filter: brightness(1.15); }
.px20 { padding-left: 20px; padding-right: 20px; }
.banner { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.banner img { object-fit: contain; flex: none; }
.banner span { flex: 1; }
.sec-title { font-size: 16px; font-weight: 500; margin: 0; }
.muted { color: var(--text2); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; }
.gap10 { gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* Overview */
.today-card .top { display: flex; align-items: center; gap: 14px; }
.today-card h2 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.stats2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.inner-stat { padding: 12px; border-radius: 16px; background: var(--chip); border: 1px solid rgba(110,124,154,.5); }
.inner-stat b { display: block; font-size: 16px; font-weight: 500; margin-top: 4px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { border-radius: 20px; padding: 14px; aspect-ratio: 1.7; display: flex; flex-direction: column; }
.tile .row { color: var(--text2); }
.tile svg.i { width: 18px; height: 18px; }
.tile .sp { flex: 1; }
.dots { display: flex; gap: 4px; margin-left: auto; }
.dot { width: 5px; height: 5px; border-radius: 50%; }
.dots.lg { gap: 5px; margin-left: 0; }
.dots.lg .dot { width: 6px; height: 6px; }
.text-btn { color: #A8BCE0; font-weight: 500; padding: 10px 12px; border-radius: 20px; }
.text-btn:hover { background: rgba(100,127,163,.15); }
.text-btn.danger { color: var(--danger); }

.btn {
  width: 100%; min-height: 52px; border-radius: 16px; background: var(--primary); color: #fff;
  font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px;
}
.btn:hover { filter: brightness(1.08); }
.btn svg.i { width: 20px; height: 20px; }
.btn.inline { width: auto; display: inline-flex; }

/* Entry card */
.entry { border-radius: 22px; padding: 14px; display: flex; gap: 14px; align-items: flex-start; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.date-badge { width: 52px; padding: 8px 0; border-radius: 14px; border: 1px solid var(--glass-border); text-align: center; flex: none; line-height: 1.25; }
.date-badge b { display: block; font-size: 18px; font-weight: 500; }
.date-badge span { display: block; font-size: 11px; color: var(--text2); }
.date-badge small { display: block; font-size: 10px; color: var(--text2); }
.entry-meta { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.entry-meta svg.i { width: 16px; height: 16px; }
.entry-meta time { margin-left: auto; font-size: 12px; }
.entry h3 { margin: 8px 0 0; font-size: 16px; font-weight: 500; line-height: 1.3; word-break: break-word; }
.entry .note { margin: 6px 0 0; color: var(--text2); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.kind-pill { display: inline-block; margin-top: 10px; padding: 6px 10px; border-radius: 999px; background: var(--chip); border: 1px solid var(--border-60); color: var(--text2); font-size: 12px; }
.entries > * { margin: 0 20px 12px; width: calc(100% - 40px); }

/* Layer card */
.layer-card { display: flex; align-items: center; margin-bottom: 12px; }
.layer-card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
.layer-card svg.i { color: var(--text2); }

/* Segmented */
.seg { display: flex; border: 1px solid rgba(110,124,154,.35); border-radius: 999px; overflow: hidden; }
.seg button { flex: 1; min-height: 40px; padding: 0 10px; background: var(--chip); font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button + button { border-left: 1px solid rgba(110,124,154,.35); }
.seg button[aria-pressed="true"] { background: rgba(62,79,114,.65); }
.seg button[aria-pressed="true"]::before { content: ""; width: 14px; height: 14px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center/contain no-repeat; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 20px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; padding: 0; }
.chip {
  flex: none; padding: 10px 14px; border-radius: 999px; font-weight: 500; white-space: nowrap;
  background: #3A4C68; border: 1px solid #7E8AAB; color: #fff;
}
.chip[aria-pressed="true"] { background: #5C6E96; }
.chip.layer { border-color: var(--c); }
.chip.layer[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 80%, transparent); border-color: var(--c); }
.chip.big { padding: 12px 16px; }

/* Day navigator */
.daynav { display: flex; align-items: center; }
.daynav .lbl { flex: 1; text-align: center; font-size: 16px; font-weight: 500; padding: 8px; border-radius: 8px; position: relative; }
.daynav .lbl:hover { background: rgba(255,255,255,.05); }
.hidden-input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; left: 50%; bottom: 0; border: 0; padding: 0; }

.overlap { padding: 4px 20px 8px; color: var(--text2); font-size: 13px; }
.day-head { padding: 16px 16px 8px; font-size: 16px; font-weight: 500; }

/* Search field */
.field-wrap { position: relative; }
.search {
  width: 100%; height: 50px; border-radius: 16px; background: var(--search);
  border: 1px solid var(--border-45); padding: 0 16px 0 48px; outline: none;
}
.search:focus { border-color: var(--primary); }
.search::placeholder { color: var(--text2); }
.field-wrap svg.i { position: absolute; left: 14px; top: 13px; color: var(--text2); }

.empty { padding: 24px; text-align: center; color: var(--text2); font-size: 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.empty.full { flex: 1; justify-content: center; }
.center-msg { flex: 1; display: grid; place-items: center; color: var(--text2); padding: 24px; }

/* FAB */
.fab {
  position: absolute; right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 18px;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.35); z-index: 5;
}
.fab:hover { filter: brightness(1.08); }

/* Insights */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-tile { border-radius: 20px; padding: 14px 12px; }
.stat-tile svg.i { width: 18px; height: 18px; color: var(--primary); }
.stat-tile b { display: block; font-size: 24px; font-weight: 500; margin-top: 10px; line-height: 1.3; }
.active-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.share-pill { padding: 6px 10px; border-radius: 999px; background: var(--chip); }
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 120px; margin-top: 16px; }
.bar-col { display: flex; flex-direction: column; align-items: stretch; }
.bar-area { flex: 1; display: flex; align-items: flex-end; }
.bar { width: 100%; border-radius: 999px; }
.bar-col span { height: 18px; line-height: 18px; text-align: center; font-size: 11px; color: var(--text2); padding-top: 4px; }
.lbar { margin-bottom: 10px; }
.lbar .track { height: 8px; border-radius: 999px; background: var(--chip); margin-top: 6px; overflow: hidden; }
.lbar .fill { height: 100%; border-radius: 999px; }
.cdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* Archive */
.week-row { display: flex; justify-content: space-between; margin-top: 12px; gap: 4px; }
.wd { width: 36px; height: 48px; border-radius: 12px; border: 1px solid var(--glass-border); display: grid; place-items: center; color: var(--text2); }
.wd.has { background: var(--chip); color: var(--text); }
.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; padding: 16px; }
.md { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--glass-border); display: grid; place-items: center; color: var(--text2); }
.md.has { background: var(--chip); color: var(--text); }
.dim { opacity: .4; }

/* Pushed pages */
.page {
  position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column;
  background: linear-gradient(135deg, var(--bg-top), var(--bg-mid) 50%, var(--bg-bottom));
  padding-top: var(--safe-t); padding-bottom: var(--safe-b);
  animation: pageIn .26s cubic-bezier(.2,.8,.2,1);
}
.page.out { animation: pageOut .2s ease-in forwards; }
@keyframes pageIn { from { opacity: 0; transform: translateY(4%); } to { opacity: 1; transform: none; } }
@keyframes pageOut { to { opacity: 0; transform: translateY(4%); } }
.appbar { height: 64px; display: flex; align-items: center; padding: 0 4px; flex: none; }
.appbar h1 { flex: 1; margin: 0 0 0 8px; font-size: 22px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page .scroll { padding: 16px; }
.page .entries > * { margin: 0 0 12px; width: 100%; }
.layer-head { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.layer-head i { width: 10px; height: 10px; border-radius: 50%; }

/* Form */
.flabel { font-size: 14px; font-weight: 500; margin: 0 0 8px; }
.kind-chip { padding: 8px 14px; }
.tile-row { display: flex; align-items: center; width: 100%; padding: 10px 0; text-align: left; position: relative; }
.tile-row .grow div:first-child { font-size: 16px; }
.tile-row svg.i { color: var(--text2); }
.tf { position: relative; margin-top: 8px; }
.tf label { position: absolute; left: 16px; top: 15px; color: var(--text2); pointer-events: none; transition: all .15s; font-size: 16px; }
.tf input, .tf textarea {
  width: 100%; border-radius: 16px; background: var(--search); border: 1px solid var(--border-45);
  padding: 22px 16px 8px; outline: none; font-size: 16px; resize: vertical;
}
.tf textarea { min-height: 120px; }
.tf input:focus, .tf textarea:focus { border-color: var(--primary); }
.tf input:focus + label, .tf input:not(:placeholder-shown) + label,
.tf textarea:focus + label, .tf textarea:not(:placeholder-shown) + label { top: 5px; font-size: 12px; }
.tf.err input { border-color: #E57373; }
.tf .help { display: flex; justify-content: space-between; font-size: 12px; color: var(--text2); padding: 4px 12px 0; }
.tf.err .help span:first-child { color: #E57373; }

/* Overlay: dialogs and sheets */
#overlay { position: absolute; inset: 0; z-index: 50; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); pointer-events: auto; animation: fade .2s; display: flex; align-items: center; justify-content: center; padding: 24px; }
.scrim.sheet-scrim { align-items: flex-end; padding: 0; }
@keyframes fade { from { opacity: 0; } }
.dialog { background: var(--sheet); border-radius: 28px; padding: 24px; max-width: 360px; width: 100%; animation: pop .2s; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.dialog h2 { margin: 0 0 12px; font-size: 22px; font-weight: 500; }
.dialog p { margin: 0; color: var(--text2); line-height: 1.45; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 20px; }
.sheet { background: var(--sheet); border-radius: 28px 28px 0 0; width: 100%; padding: 16px 0 calc(16px + var(--safe-b)); animation: up .25s; }
@keyframes up { from { transform: translateY(100%); } }
.sheet .handle { width: 32px; height: 4px; border-radius: 2px; background: var(--text2); opacity: .5; margin: 0 auto 12px; }
.sheet button { display: flex; align-items: center; gap: 24px; width: 100%; padding: 16px 24px; font-size: 16px; }
.sheet button:hover { background: rgba(255,255,255,.05); }
.sheet .danger { color: var(--danger); }

#snack {
  position: absolute; left: 16px; right: 16px; bottom: calc(84px + var(--safe-b)); z-index: 60;
  background: #2C3A52; color: var(--text); font-weight: 500; border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.35); transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#snack.show { opacity: 1; transform: none; }

.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }

@media (max-width: 360px) {
  .hdr h1 { font-size: 24px; }
  .stat-tile b { font-size: 20px; }
  .wd { width: 32px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
