/* Second brain — night notebook. One warm lamp accent on deep ink. */
:root {
  --ink: #0f1626;
  --ink-raised: #18213a;
  --ink-line: #253150;
  --mist: #c9d2e8;
  --mist-dim: #7d89a8;
  --lamp: #f2c66d;
  --lamp-soft: rgba(242, 198, 109, .14);
  --moss: #8fc7a4;
  --rose: #e8828f;
  --serif: "Literata", Georgia, serif;
  --sans: "Onest", -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--ink); color: var(--mist); }
body { font: 15px/1.5 var(--sans); padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }

/* ---------- views ---------- */
.view { display: none; padding: 20px 18px 28px; max-width: 640px; margin: 0 auto; }
.view.active { display: block; }
.view-graph.active { padding: 0; max-width: none; }

.page-title { font: 600 26px/1.15 var(--serif); margin: 6px 0 18px; letter-spacing: -.01em; }
.section-title { font: 500 13px/1.4 var(--sans); color: var(--mist-dim); margin: 28px 0 10px; }
.empty { color: var(--mist-dim); font: italic 16px/1.6 var(--serif); margin: 18px 0; }
.back { border: 0; background: none; color: var(--mist-dim); padding: 0; margin-bottom: 4px; font-size: 14px; }

/* ---------- today: the one bold element ---------- */
.day-head { padding-top: 8px; }
.day-weekday { color: var(--mist-dim); font-size: 14px; }
.day-date { font: 400 46px/1.02 var(--serif); letter-spacing: -.025em; margin: 2px 0 18px; }
.day-date em { font-style: italic; color: var(--mist-dim); font-size: .55em; letter-spacing: 0; margin-left: 6px; }
.horizon { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 64px; }
.horizon .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.horizon .bar { width: 100%; max-width: 30px; border-radius: 3px 3px 1px 1px; background: var(--ink-line); min-height: 3px;
  transition: height .5s cubic-bezier(.2, .8, .2, 1); }
.horizon .bar.scored { background: color-mix(in srgb, var(--mist) 45%, var(--ink-line)); }
.horizon .col.today .bar { background: var(--lamp); box-shadow: 0 0 18px var(--lamp-soft); }
.horizon .lbl { font-size: 11px; color: var(--mist-dim); line-height: 1; }
.horizon .col.today .lbl { color: var(--lamp); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 22px; border-top: 1px solid var(--ink-line); }
.metric { padding: 12px 4px 0 0; }
.metric dt { font-size: 12px; color: var(--mist-dim); }
.metric dd { margin: 2px 0 0; font: 400 21px/1.2 var(--serif); }
.metric dd.none { color: var(--ink-line); }
.metric dd small { font-size: 13px; color: var(--mist-dim); }

.birthday { margin-top: 18px; padding: 10px 14px; border-radius: 12px; background: var(--lamp-soft); color: var(--lamp); }
.summary { font: italic 17px/1.65 var(--serif); color: var(--mist); margin: 0; }

.timeline { position: relative; margin-left: 4px; }
.entry { display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 0 0 18px; position: relative; }
.entry::before { content: ""; position: absolute; left: 52px; top: 8px; bottom: -4px; width: 1px; background: var(--ink-line); }
.entry:last-child::before { display: none; }
.entry time { font-size: 13px; color: var(--mist-dim); padding-top: 2px; font-variant-numeric: tabular-nums; }
.entry .text { font: 16px/1.6 var(--serif); padding-left: 10px; overflow-wrap: anywhere; }
.entry .kind { font: 12px var(--sans); color: var(--mist-dim); margin-left: 6px; }
.entry .links { margin-top: 4px; font: 13px var(--sans); }
.entry .links a { color: var(--lamp); text-decoration: none; margin-right: 10px; }

/* ---------- checklist ---------- */
.add-task { display: grid; gap: 10px; padding: 14px; border-radius: 16px; background: var(--ink-raised); }
.add-task input[type=text] { width: 100%; border: 0; background: transparent; font: 17px var(--serif); outline: none; padding: 2px 0; }
.add-task input[type=text]::placeholder { color: var(--mist-dim); }
.when-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill { border: 1px solid var(--ink-line); background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--mist-dim); }
.pill.on { border-color: var(--lamp); color: var(--lamp); background: var(--lamp-soft); }
.pill input { border: 0; background: transparent; color: inherit; font-size: 13px; width: 112px; }
.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 500; background: var(--lamp); color: #1a1406; }
.btn.ghost { background: transparent; color: var(--mist); border: 1px solid var(--ink-line); }
.btn.danger { background: transparent; color: var(--rose); border: 1px solid color-mix(in srgb, var(--rose) 40%, transparent); }
.btn[disabled] { opacity: .45; }
.add-task .btn { justify-self: end; }

.group-title { font-size: 13px; color: var(--mist-dim); margin: 22px 0 4px; }
.group-title.overdue { color: var(--rose); }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--ink-line); }
.task:last-child { border-bottom: 0; }
.check { flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--mist-dim);
  background: transparent; display: grid; place-items: center; padding: 0; }
.check svg { width: 12px; height: 12px; stroke: var(--ink); stroke-width: 3; fill: none; opacity: 0; }
.task.done .check { background: var(--moss); border-color: var(--moss); }
.task.done .check svg { opacity: 1; }
.task .body { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; }
.task .title { font: 16px/1.45 var(--serif); overflow-wrap: anywhere; }
.task.done .title { color: var(--mist-dim); text-decoration: line-through; text-decoration-color: var(--ink-line); }
.task .due { font-size: 12px; color: var(--mist-dim); }
.task .due.overdue { color: var(--rose); }
.task.leaving { animation: leave .35s ease forwards; }
@keyframes leave { to { opacity: 0; transform: translateX(16px); } }
.toggle-done { border: 0; background: none; color: var(--mist-dim); padding: 14px 0 0; font-size: 14px; }

/* ---------- graph ---------- */
.graph-tools { position: absolute; z-index: 2; inset: 12px 12px auto; display: grid; gap: 8px; pointer-events: none; }
.graph-tools > * { pointer-events: auto; }
#graph-search { width: 100%; border: 1px solid var(--ink-line); background: color-mix(in srgb, var(--ink) 85%, transparent);
  backdrop-filter: blur(8px); border-radius: 12px; padding: 10px 14px; outline: none; }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filter { flex: none; display: flex; align-items: center; gap: 6px; border: 1px solid var(--ink-line); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; background: color-mix(in srgb, var(--ink) 85%, transparent); color: var(--mist-dim); }
.filter.on { color: var(--mist); }
.filter i { width: 8px; height: 8px; border-radius: 50%; }
.filter:not(.on) i { opacity: .3; }
#graph { width: 100%; height: calc(100vh - var(--tabbar-h)); }
.view-graph .empty { position: absolute; top: 45%; left: 0; right: 0; text-align: center; padding: 0 32px; }

/* ---------- people ---------- */
.person { display: flex; gap: 14px; align-items: center; width: 100%; border: 0; background: none; text-align: left;
  padding: 12px 0; border-bottom: 1px solid var(--ink-line); }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font: 600 16px var(--serif); color: var(--ink); }
.person .name { font: 17px/1.3 var(--serif); }
.person .sub { font-size: 13px; color: var(--mist-dim); }
.person .fact { font-size: 13px; color: var(--mist); opacity: .8; margin-top: 2px; display: -webkit-box;
  -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.nudge { padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--ink-line); color: var(--mist-dim); margin-bottom: 8px; }
.nudge b { color: var(--mist); font-weight: 500; }

/* ---------- more / lists ---------- */
.menu-item { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; background: none;
  padding: 16px 0; border-bottom: 1px solid var(--ink-line); font: 18px var(--serif); text-align: left; }
.menu-item span { font: 13px var(--sans); color: var(--mist-dim); }

/* calendar + heatmap */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { font: 400 20px var(--serif); text-transform: capitalize; }
.cal-head button { border: 0; background: var(--ink-raised); width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .wd { text-align: center; font-size: 11px; color: var(--mist-dim); padding-bottom: 2px; }
.cal .d { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: 13px; color: var(--mist-dim);
  border: 0; background: var(--ink-raised); padding: 0; position: relative; }
.cal .d.has { color: var(--mist); }
.cal .d.has::after { content: ""; position: absolute; bottom: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--lamp); }
.cal .d.today { box-shadow: inset 0 0 0 1.5px var(--lamp); }
.cal .d.blank { visibility: hidden; }
.heat-wrap { overflow-x: auto; padding-bottom: 6px; direction: rtl; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 3px; direction: ltr; width: max-content; }
.heat i { width: 11px; height: 11px; border-radius: 2.5px; background: var(--ink-raised); }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--lamp) 25%, var(--ink-raised)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--lamp) 50%, var(--ink-raised)); }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--lamp) 75%, var(--ink-raised)); }
.heat i[data-l="4"] { background: var(--lamp); }

/* goals */
.goal { padding: 16px 0; border-bottom: 1px solid var(--ink-line); }
.goal .name { font: 18px/1.3 var(--serif); }
.goal.done .name { color: var(--mist-dim); }
.goal .sub { font-size: 13px; color: var(--mist-dim); margin: 2px 0 10px; }
.weeks { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; align-items: end; height: 34px; }
.weeks i { background: var(--ink-line); border-radius: 2px; min-height: 3px; }
.weeks i.on { background: var(--moss); }
.goal .actions { display: flex; gap: 8px; margin-top: 12px; }
.goal .actions button { font-size: 13px; padding: 6px 12px; }

/* insights */
.insight { font: 17px/1.6 var(--serif); padding: 12px 0; border-bottom: 1px solid var(--ink-line); margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; }
.tags span { font-family: var(--serif); color: var(--mist); }

/* settings */
.setting { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 16px 0;
  border-bottom: 1px solid var(--ink-line); }
.setting .label { font: 17px var(--serif); }
.setting .hint { grid-column: 1 / -1; font-size: 13px; color: var(--mist-dim); }
.setting input[type=time] { background: var(--ink-raised); border: 0; border-radius: 8px; padding: 4px 8px; color: var(--mist); }
.switch { width: 46px; height: 28px; border-radius: 999px; border: 0; background: var(--ink-line); position: relative; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--mist); transition: transform .2s ease; }
.switch[aria-checked="true"] { background: var(--lamp); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: #1a1406; }
.setting-controls { display: flex; gap: 10px; align-items: center; }

/* ---------- tabbar ---------- */
.tabbar { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--ink) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--ink-line); }
.tabbar button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--mist-dim); font-size: 11px; }
.tabbar svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--lamp); }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; z-index: 19; background: rgba(4, 7, 14, .55); }
.sheet { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: var(--ink-raised);
  border-radius: 22px 22px 0 0; padding: 10px 20px calc(28px + env(safe-area-inset-bottom)); animation: rise .24s cubic-bezier(.2, .8, .2, 1); }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet .grip { width: 38px; height: 4px; border-radius: 2px; background: var(--ink-line); margin: 0 auto 14px; }
.sheet h2 { font: 400 26px/1.15 var(--serif); margin: 0 0 6px; }
.sheet .meta { font-size: 13px; color: var(--mist-dim); margin-bottom: 12px; }
.sheet label { display: block; font-size: 13px; color: var(--mist-dim); margin: 14px 0 6px; }
.sheet input[type=text], .sheet input[type=date], .sheet input[type=time] { width: 100%; background: var(--ink); border: 1px solid var(--ink-line);
  border-radius: 10px; padding: 10px 12px; color: var(--mist); outline: none; }
.sheet .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet .buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.markdown { font: 16px/1.65 var(--serif); }
.markdown h1 { display: none; }
.markdown h2 { font: 500 13px var(--sans); color: var(--mist-dim); margin: 22px 0 6px; }
.markdown h3 { font: 500 14px var(--sans); margin: 18px 0 4px; color: var(--mist-dim); }
.markdown blockquote { margin: 6px 0; padding: 2px 0 2px 14px; border-left: 2px solid var(--lamp); }
.markdown blockquote p { margin: 0; }
.markdown p { margin: 8px 0; }
.markdown ul { padding-left: 18px; }
.markdown img { max-width: 100%; border-radius: 12px; }
.markdown a.wikilink { color: var(--lamp); text-decoration: none; }
.markdown a.wikilink.missing { color: var(--mist-dim); }
.backlinks { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 6px; }
.backlinks a { padding: 5px 11px; border-radius: 999px; background: var(--ink); font-size: 13px; color: var(--mist); text-decoration: none; }

/* ---------- toast / fatal ---------- */
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--mist); color: var(--ink); padding: 9px 16px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); white-space: nowrap; }
.fatal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 32px; text-align: center;
  background: var(--ink); color: var(--mist-dim); font: italic 18px/1.6 var(--serif); }

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