@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("assets/fonts/plus-jakarta-sans.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #162A38;
  --deep: #244756;
  --teal: #4F8F8B;
  --mist: #8FAEB4;
  --sand: #D6B98C;
  --clay: #B97868;
  --ink: #152027;
  --white: #F8FAF8;
  --card: #294F5B;
  --sec: #AFC1C3;
  --divider: #355563;
  --connector: #54717A;
  --outline: #E2C99E;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--navy);
  color: var(--white);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.43;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--navy);
}

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  padding-top: env(safe-area-inset-top, 0px);
}
.appbar-row {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 4px 0 16px;
  gap: 4px;
}
.appbar-row.has-back { padding-left: 4px; }
.appbar h1 {
  flex: 1;
  margin: 0;
  font-size: 23px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar-bottom { padding: 0 16px 8px; }

.icon-btn {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--white);
  flex: none;
}
.icon-btn:hover { background: rgba(248, 250, 248, .08); }
.icon-btn:active { background: rgba(248, 250, 248, .14); }
.icon-btn:disabled { opacity: .5; cursor: default; }
.icon-btn.muted { color: var(--sec); width: 40px; height: 40px; margin: -8px -8px 0 0; }
svg.ic { width: 24px; height: 24px; fill: currentColor; flex: none; }
.badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #F2B8B5;
  color: #601410;
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  text-align: center;
}

/* ---------- Layout ---------- */
.content {
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px);
}
.content.flush { padding: 0 0 calc(var(--nav-h) + var(--safe-b) + 24px); }
.content.page { padding-bottom: calc(24px + var(--safe-b)); }
.content.fab-space { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 88px); }
.gap8 { height: 8px; } .gap12 { height: 12px; } .gap16 { height: 16px; } .gap24 { height: 24px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.row.g12 { gap: 12px; }

.title-l { font-size: 23px; font-weight: 500; line-height: 1.25; }
.title-m { font-size: 16px; font-weight: 500; line-height: 1.5; letter-spacing: .15px; }
.title-s { font-size: 14px; font-weight: 500; line-height: 1.43; letter-spacing: .1px; }
.sec { color: var(--sec); }
.small { font-size: 12px; }
.label-strong { font-weight: 600; margin-bottom: 8px; }
.section-title { padding: 20px 16px 8px; }
.section-hint { padding: 4px 16px; color: var(--sec); line-height: 1.4; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: .5px solid var(--divider);
  border-radius: 12px;
  overflow: hidden;
}
.card.pad { padding: 16px; }
.card.m { margin: 6px 16px; }
.card.mb8 { margin-bottom: 8px; }
.tap { cursor: pointer; transition: background-color .15s; }
.tap:hover { background-color: #2E5663; }
.tap:active { background-color: #335c69; }

/* ---------- Scenes ---------- */
.scene {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: var(--deep);
  height: 168px;
}
.scene img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.scene::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.15), rgba(0,0,0,.72));
}
.scene-text {
  position: absolute; left: 16px; right: 16px; bottom: 16px;
  z-index: 1;
}
.scene-text .sub { margin-top: 4px; color: var(--sec); }

.pager {
  margin: 8px 16px 0;
  height: 176px;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: 12px;
}
.pager::-webkit-scrollbar { display: none; }
.pager .slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  padding-right: 4px;
  height: 100%;
}
.pager .slide-in {
  position: relative; height: 100%;
  border-radius: 12px; overflow: hidden;
  background: var(--deep);
}
.pager img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pager .slide-in::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(22,42,56,.85), rgba(22,42,56,0));
}
.pager .scene-text { font-size: 16px; font-weight: 500; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--divider); transition: background .2s, width .2s; }
.dots span.on { background: var(--teal); width: 14px; border-radius: 3px; }

/* ---------- Stats ---------- */
.stats { padding: 12px; display: grid; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 359px) { .stats { grid-template-columns: repeat(2, 1fr); row-gap: 8px; } }
.stat {
  margin: 4px; padding: 12px;
  background: var(--deep);
  border: .5px solid var(--divider);
  border-radius: 12px;
  min-width: 0;
}
.stat .dot { width: 8px; height: 8px; border-radius: 50%; margin-bottom: 8px; }
.stat .v { font-size: 28px; line-height: 1.29; font-weight: 500; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; margin: -4px; }
.summary { margin: 4px; padding: 16px; background: var(--deep); border-radius: 12px; }
.summary .v { font-size: 28px; line-height: 1.29; font-weight: 600; }

.metric img { display: block; width: 100%; height: 72px; object-fit: cover; }
.metric .body { padding: 12px; }
.metric .v { font-size: 24px; line-height: 1.33; font-weight: 500; }

/* ---------- Badges ---------- */
.pill {
  display: inline-block;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.33;
  white-space: nowrap;
}
.pill.compact { padding: 4px 8px; font-size: 11px; }
.pill.note { padding: 4px 10px; font-size: 11px; }
.s-waiting { background: var(--mist); color: var(--ink); }
.s-active { background: var(--teal); color: var(--white); }
.s-closed { background: var(--clay); color: var(--white); }
.n-detail { background: var(--teal); color: var(--white); }
.n-question { background: var(--mist); color: var(--ink); }
.n-inspiration { background: var(--sand); color: var(--ink); }
.n-revision { background: rgba(185, 120, 104, .85); color: var(--white); }

/* ---------- Idea / note cards ---------- */
.compact-idea { display: flex; align-items: center; gap: 12px; padding: 16px; }
.compact-idea .grow { flex: 1; min-width: 0; }
.compact-idea .title-s { overflow-wrap: anywhere; }
.idea-card { padding: 16px; }
.idea-head { display: flex; align-items: flex-start; gap: 8px; }
.idea-head .title-m { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.clamp2, .clamp3, .clamp5 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp3 { -webkit-line-clamp: 3; line-clamp: 3; }
.clamp5 { -webkit-line-clamp: 5; line-clamp: 5; }
.desc { margin-top: 8px; color: var(--sec); line-height: 1.4; overflow-wrap: anywhere; white-space: pre-line; }
.meta { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--sec); }
.meta .ncount { display: inline-flex; align-items: center; gap: 4px; }
.meta .ncount svg { width: 14px; height: 14px; fill: currentColor; }
.note-card { padding: 16px; }
.note-card .idea-t { color: var(--teal); }
.note-card .line { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.note-card .txt { margin-top: 8px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- Buttons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  width: 100%;
  padding: 0 24px;
  border-radius: 12px;
  border: 0;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: .1px;
  transition: filter .15s, background-color .15s;
}
.btn.filled { background: var(--teal); color: var(--white); }
.btn.filled:hover { filter: brightness(1.08); }
.btn.filled:active { filter: brightness(1.15); }
.btn.outlined { background: transparent; color: var(--white); border: 1px solid var(--connector); }
.btn.outlined:hover { background: rgba(248,250,248,.06); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.auto { width: auto; display: inline-flex; }
.stack > .btn + .btn { margin-top: 8px; }
.text-btn {
  background: transparent; border: 0;
  color: var(--teal);
  font-weight: 500;
  padding: 10px 12px;
  border-radius: 20px;
  min-height: 40px;
}
.text-btn:hover { background: rgba(79,143,139,.12); }
.text-btn.danger { color: var(--clay); }
.text-btn.inline { padding: 8px 12px; margin-left: -12px; }

/* ---------- Chips & segmented ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  border: 1px solid var(--divider);
  background: var(--deep);
  color: var(--white);
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: rgba(79,143,139,.35); }
.chip.on::before {
  content: "";
  width: 12px; height: 7px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -2px);
}
.seg {
  display: flex;
  border: 1px solid var(--connector);
  border-radius: 20px;
  overflow: hidden;
  height: 40px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--white);
  font-weight: 500;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 0;
  padding: 0 8px;
}
.seg button + button { border-left: 1px solid var(--connector); }
.seg button.on { background: rgba(143,174,180,.28); }
.seg button.on::before {
  content: "";
  width: 11px; height: 6px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translate(1px, -2px);
  flex: none;
}

/* ---------- Inputs ---------- */
.field { position: relative; }
.field .box {
  position: relative;
  background: var(--deep);
  border: 1px solid var(--divider);
  border-radius: 12px;
  transition: border-color .15s;
}
.field .box:focus-within { border-color: var(--teal); box-shadow: inset 0 0 0 .5px var(--teal); }
.field label {
  position: absolute; left: 12px; top: 6px;
  font-size: 12px; color: var(--sec);
  pointer-events: none;
}
.field .box:focus-within label { color: var(--teal); }
.field input, .field textarea, .field select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--white);
  font-size: 16px;
  padding: 24px 12px 10px;
  border-radius: 12px;
}
.field textarea { resize: vertical; line-height: 1.5; display: block; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.field select option { background: var(--deep); color: var(--white); }
.field .caret { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--sec); }
.field .counter { text-align: right; font-size: 12px; color: var(--sec); padding: 4px 12px 0; }
.field.plain input { padding: 14px 12px 14px 48px; }
.field.plain .lead { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--sec); }
.field input::placeholder, .field textarea::placeholder { color: var(--sec); }

/* ---------- Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 32px;
  color: var(--sec);
  font-size: 16px;
  line-height: 1.5;
}
.empty.fill { min-height: calc(100dvh - 64px - var(--nav-h) - 40px); }
.empty svg.ic { width: 48px; height: 48px; margin-bottom: 16px; }
.empty .btn { margin-top: 24px; width: auto; }

/* ---------- Distribution / charts ---------- */
.dist-bar {
  display: flex; height: 16px; border-radius: 8px; overflow: hidden;
  background: var(--deep);
  transform-origin: left center;
  animation: growX .3s ease-out both;
}
@keyframes growX { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.dist-bar span { height: 100%; }
.legend { margin-top: 12px; }
.legend div { display: flex; align-items: center; gap: 8px; color: var(--sec); font-size: 13px; margin-bottom: 4px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

.cat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cat-row .lbl { width: 72px; font-size: 12px; color: var(--sec); flex: none; }
.cat-row .track { flex: 1; height: 8px; border-radius: 4px; background: var(--deep); overflow: hidden; }
.cat-row .track span { display: block; height: 100%; background: var(--teal); border-radius: 4px; transition: width .3s; }

.chart { padding: 12px 12px 10px; }
.chart-legend { display: flex; justify-content: center; gap: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: var(--sec); }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.bars { display: flex; height: 124px; margin-top: 10px; }
.bar-col { flex: 1; min-width: 0; padding: 0 3px; display: flex; flex-direction: column; }
.bar-col .area { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-height: 0; }
.bar-col .cnt { font-size: 10px; line-height: 1; color: var(--sec); margin-bottom: 4px; }
.bar-col .bar { width: 100%; border-radius: 4px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; background: var(--deep); }
.bar-col .bar span { display: block; width: 100%; }
.bar-col .lab { margin-top: 4px; font-size: 10px; line-height: 1.1; color: var(--sec); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.no-activity { height: 116px; display: flex; align-items: center; justify-content: center; color: var(--sec); font-size: 12px; margin-top: 10px; }

.list-tile { display: flex; align-items: center; gap: 16px; padding: 12px 16px; min-height: 56px; }
.list-tile .t { flex: 1; font-size: 16px; }

/* ---------- Journey ---------- */
.track-row { display: flex; align-items: center; }
.track-row .line { flex: 1; height: 2px; background: var(--connector); }
.node {
  width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.node:hover { background: rgba(248,250,248,.06); }
.node i {
  display: block; border-radius: 50%;
  width: 22px; height: 22px;
  border: 1.5px solid var(--c);
  background: transparent;
  transition: all .25s;
}
.node.cur i { width: 28px; height: 28px; border: 2px solid var(--outline); background: var(--c); }
.track-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--sec); margin-top: 2px; }
.track-labels span { width: 48px; text-align: center; }

.hist { display: flex; gap: 12px; padding: 8px 0; align-items: flex-start; }
.hist.tap { border-radius: 8px; }
.hist .mk { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.hist .t { font-weight: 500; }
.hist .st { margin-top: 4px; color: var(--sec); line-height: 1.4; overflow-wrap: anywhere; white-space: pre-line; }
.hist .d { margin-top: 4px; color: var(--sec); font-size: 12px; }
.idea-desc { color: var(--white); line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- Bottom navigation ---------- */
.navbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--navy);
  display: flex;
  box-shadow: 0 -1px 0 rgba(53,85,99,.6);
}
.navbar button {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--sec);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
}
.navbar .pillbg {
  width: 64px; height: 32px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .2s;
}
.navbar button.on { color: var(--teal); }
.navbar button.on .pillbg { background: var(--deep); }
.navbar button:hover:not(.on) .pillbg { background: rgba(248,250,248,.06); }
#app.page-mode .navbar, #app.page-mode .fab { display: none; }

.fab {
  position: fixed;
  z-index: 31;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  right: max(16px, calc((100vw - 640px) / 2 + 16px));
  width: 56px; height: 56px;
  border-radius: 16px;
  border: 0;
  background: var(--teal);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 6px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.25);
  transition: filter .15s, transform .15s;
}
.fab:hover { filter: brightness(1.08); }
.fab:active { transform: scale(.96); }

/* ---------- Overlays ---------- */
.scrim {
  position: fixed; inset: 0;
  z-index: 50;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.dialog {
  width: 100%; max-width: 360px;
  background: #1F3A47;
  border-radius: 28px;
  padding: 24px;
  max-height: calc(100dvh - 48px);
  overflow: auto;
  animation: pop .18s ease-out;
}
.dialog.dark-card { background: var(--card); }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
.dialog h2 { margin: 0 0 16px; font-size: 24px; font-weight: 400; line-height: 1.33; }
.dialog p { margin: 0 0 8px; color: var(--sec); line-height: 1.43; }
.dialog .actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.dialog .actions .btn { width: auto; min-height: 40px; border-radius: 20px; }

.scrim.sheet-scrim { align-items: flex-end; padding: 0; }
.sheet {
  width: 100%; max-width: 640px;
  background: var(--deep);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b));
  max-height: 90dvh;
  overflow: auto;
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(100%); } }
.sheet .chip { background: var(--card); }
.sheet .chip.on { background: rgba(79,143,139,.55); }
.sheet .head { display: flex; justify-content: space-between; align-items: center; }

.menu {
  position: fixed;
  z-index: 60;
  min-width: 140px;
  background: #2B4A57;
  border-radius: 4px;
  padding: 8px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  animation: fade .12s ease-out;
}
.menu button {
  display: block; width: 100%;
  text-align: left;
  background: transparent; border: 0;
  padding: 0 16px; height: 48px;
  font-size: 16px;
}
.menu button:hover { background: rgba(248,250,248,.08); }
.menu-scrim { position: fixed; inset: 0; z-index: 59; }

.snack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  transform: translate(-50%, 20px);
  width: calc(100% - 24px);
  max-width: 600px;
  background: #EDF2F0;
  color: #1B2B33;
  padding: 14px 16px;
  border-radius: 4px;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.snack.show { opacity: 1; transform: translate(-50%, 0); }
.snack.low { bottom: calc(12px + var(--safe-b)); }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--teal); border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

:focus-visible { outline: 2px solid var(--outline); outline-offset: 2px; }
.field :focus-visible { outline: none; }

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