/* LockedMind — the one stylesheet. Night to dawn: a better day looks lighter.
   Gold means a person or Keyholder AI is involved (same rule as LockedFit). Ember marks need and spicy.
   Borders are inset box-shadows. One display face (Newsreader) for numbers, titles and written words,
   one text face (Instrument Sans) for everything else. */
:root {
  --ink: #0e1320; --card: #161d2c; --card2: #1c2436; --line: #262f44;
  --fg: #e9ecf3; --mute: #8e98ad; --dim: #5d677c;
  --gold: #d4af37; --gold-bg: rgba(212, 175, 55, .13); --need: #c98a6f; --bad: #e48b77;
  --mood1: #5b6479; --mood2: #6f81ae; --mood3: #95abcc; --mood4: #b7d2c7; --mood5: #ecdfae;
  --f-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --tabs-h: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--fg); font-family: var(--f-body); font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; min-height: 100dvh; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--mood3); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 40px; }
.h1 { font-family: var(--f-display); font-size: 32px; line-height: 1.05; font-weight: 500; margin: 0; }
.h2 { font-family: var(--f-display); font-size: 22px; line-height: 1.15; font-weight: 500; margin: 0; }
.mute { color: var(--mute); }
.small { font-size: 12.5px; }
.lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--mute); font-weight: 600; }
.serif { font-family: var(--f-display); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--mute); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.card { background: var(--card); border-radius: 16px; padding: 14px 15px; display: flex; flex-direction: column; gap: 10px; }
.card.gold { background: var(--gold-bg); }
.card .t { font-weight: 600; }
.who { font-size: 12px; color: var(--gold); font-weight: 600; }
.q { font-family: var(--f-display); font-size: 18px; line-height: 1.3; }
.empty { color: var(--mute); text-align: center; padding: 28px 12px; }

.btn { display: block; width: 100%; text-align: center; background: var(--fg); color: var(--ink); border-radius: 999px; padding: 13px 16px; font-weight: 600; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1px rgba(228, 139, 119, .4); }
.btn.sm { display: inline-block; width: auto; padding: 7px 14px; font-size: 13px; }
.btn-lf { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: var(--fg); color: var(--ink);
  border-radius: 999px; padding: 14px 16px; font-weight: 600; font-size: 15px; text-decoration: none; }
.btn-lf img { width: 20px; height: 22px; object-fit: contain; filter: brightness(0); }

/* counters strip on Today */
.ctrs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ctr { background: var(--card); border-radius: 14px; padding: 11px 11px 10px; display: flex; flex-direction: column; gap: 2px; text-align: left; min-width: 0; }
.ctr .n { font-family: var(--f-display); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.ctr .n small { font-family: var(--f-body); font-size: 12px; color: var(--mute); margin-left: 2px; }
.ctr .l { font-size: 11.5px; font-weight: 600; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctr .s { font-size: 10.5px; color: var(--mute); }
.ctr.add { align-items: center; justify-content: center; color: var(--mute); box-shadow: inset 0 0 0 1px var(--line); background: transparent; font-size: 13px; }

/* mood picker */
.moods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; }
.md { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; color: var(--mute); padding: 2px 0; }
.md i { width: 44px; height: 44px; border-radius: 50%; display: block; transition: transform .15s; }
.md:active i { transform: scale(.94); }
.md.sel { color: var(--fg); font-weight: 600; }
.md.sel i { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--fg); }
.m1 { background: var(--mood1); } .m2 { background: var(--mood2); } .m3 { background: var(--mood3); } .m4 { background: var(--mood4); } .m5 { background: var(--mood5); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 6px 12px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); color: var(--fg); }
.chip.on { background: var(--fg); color: var(--ink); box-shadow: none; font-weight: 600; }
.chip.auto { color: var(--mute); cursor: default; }
.chip.auto::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; opacity: .7; }

/* need slider */
.need-head { display: flex; justify-content: space-between; align-items: baseline; }
.need-val { font-size: 13px; font-weight: 600; color: var(--need); }
input[type=range].need { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; }
input[type=range].need::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--mood3), var(--need)); }
input[type=range].need::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--mood3), var(--need)); }
input[type=range].need::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--fg); margin-top: -8px; box-shadow: 0 0 0 3px var(--ink); }
input[type=range].need::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--fg); border: 0; box-shadow: 0 0 0 3px var(--ink); }
input[type=range].need.unset::-webkit-slider-runnable-track { background: var(--line); }
input[type=range].need.unset::-moz-range-track { background: var(--line); }
input[type=range].need.unset::-webkit-slider-thumb { background: var(--mute); }
.ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--mute); }

textarea.words { width: 100%; min-height: 84px; resize: vertical; background: var(--card); border: 0; border-radius: 14px; padding: 12px 13px;
  font-family: var(--f-display); font-size: 17px; line-height: 1.4; color: var(--fg); outline: none; box-shadow: inset 0 0 0 1px transparent; }
textarea.words:focus { box-shadow: inset 0 0 0 1px var(--line); }
/* 16px on every text input: iPhone zooms the page into any field set smaller than that */
input.field { width: 100%; background: var(--card); border: 0; border-radius: 12px; padding: 12px 13px; color: var(--fg); outline: none; font-size: 16px; }
input.field:focus { box-shadow: inset 0 0 0 1px var(--line); }

.chk { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 4px 0; }
.chk .box { width: 22px; height: 22px; border-radius: 6px; box-shadow: inset 0 0 0 1.5px var(--mute); flex: none; margin-top: 1px; position: relative; }
.chk.on .box { background: var(--gold); box-shadow: none; }
.chk.on .box::after { content: ""; position: absolute; left: 7.5px; top: 3.5px; width: 5px; height: 11px; border: solid var(--ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.chk b { display: block; font-size: 14px; }
.chk span { display: block; font-size: 12px; color: var(--mute); line-height: 1.4; }

/* check-ins listed under Today */
.ck { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.ck:first-child { border-top: 0; padding-top: 2px; }
.ck .time { font-size: 12px; color: var(--mute); width: 52px; flex: none; padding-top: 2px; font-variant-numeric: tabular-nums; }
.ck .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ck .tags { font-size: 12.5px; color: var(--mute); }
.ck .w { font-family: var(--f-display); font-size: 15px; }

/* counters screen */
.ctr-card { background: var(--card); border-radius: 16px; padding: 14px 15px; display: flex; flex-direction: column; gap: 8px; }
.ctr-card .row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ctr-card .big { font-family: var(--f-display); font-size: 32px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ctr-card .big small { font-family: var(--f-body); font-size: 13px; color: var(--mute); margin: 0 6px 0 2px; }
.tag { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); box-shadow: inset 0 0 0 1px var(--line); border-radius: 4px; padding: 2px 6px; font-weight: 600; vertical-align: 2px; }
.goal { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.goal i { display: block; height: 100%; background: var(--mood4); }
.goal.kh i { background: var(--gold); }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 30px; }
.hist i { width: 12px; border-radius: 3px 3px 0 0; background: var(--mood3); display: block; }
.hist i.cur { background: transparent; box-shadow: inset 0 0 0 1.5px var(--mood4); }

/* insights: #ins is one child of .screen, so it needs its own gap or its cards touch */
#ins, #sl { display: flex; flex-direction: column; gap: 14px; }
/* invite: suggested usernames under the field */
.suggest { display: flex; flex-direction: column; background: var(--card); border-radius: 12px; overflow: hidden; }
.suggest:empty { display: none; }
.suggest button { text-align: left; padding: 11px 14px; font-size: 15px; border-top: 1px solid var(--line); }
.suggest button:first-child { border-top: 0; }
.suggest button:active, .suggest button:focus-visible { background: var(--card2); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border-radius: 999px; padding: 3px; font-size: 13px; text-align: center; color: var(--mute); }
.seg button { padding: 7px 0; border-radius: 999px; }
.seg .on { background: var(--card2); color: var(--fg); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { fill: var(--mute); font-size: 10px; font-family: var(--f-body); }
.scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--mute); }
.scale span { display: flex; align-items: center; gap: 5px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; font-size: 10.5px; color: var(--mute); text-align: center; }
.cal i { display: block; aspect-ratio: 1.5; border-radius: 6px; max-width: 100%; }
.cal i.none { box-shadow: inset 0 0 0 1px var(--line); }
.cal i.future { box-shadow: inset 0 0 0 1px rgba(38, 47, 68, .5); }
.cal i.today { box-shadow: 0 0 0 1.5px var(--fg); }
.stat-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 6px 0; border-top: 1px solid var(--line); }
.stat-row:first-child { border-top: 0; }
.stat-row b { font-variant-numeric: tabular-nums; }

/* journal */
#jl { display: flex; flex-direction: column; gap: 10px; }
.jday { font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); font-weight: 600; margin-top: 6px; }
.jcard { background: var(--card); border-radius: 16px; padding: 13px 15px; display: flex; flex-direction: column; gap: 6px; text-align: left; width: 100%; }
.jcard .t { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; }
.jcard .x { font-family: var(--f-display); font-size: 15.5px; line-height: 1.4; color: var(--fg); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.jmeta { font-size: 12.5px; color: var(--mute); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.gold-line { font-size: 12.5px; color: var(--gold); display: flex; gap: 7px; align-items: center; }
.gold-line::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex: none; }
.star { width: 36px; height: 36px; display: grid; place-items: center; color: var(--mute); }
.star svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.star.on { color: var(--mood5); }
.star.on svg { fill: currentColor; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 0 12px; }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--mute); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; padding: 11px 0; color: var(--fg); font-size: 16px; }
.ebody { font-family: var(--f-display); font-size: 18px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.etitle { font-family: var(--f-display); font-size: 26px; line-height: 1.15; font-weight: 500; margin: 0; }
.qa { display: flex; flex-direction: column; gap: 4px; }
.qa .qq { font-size: 13px; color: var(--mute); font-weight: 600; }
.prompt-q { font-family: var(--f-display); font-style: italic; font-size: 17px; line-height: 1.35; color: var(--mute); }
input.title-in { width: 100%; background: transparent; border: 0; outline: none; color: var(--fg); font-family: var(--f-display); font-size: 24px; padding: 2px 0; }
input.title-in::placeholder { color: var(--dim); }
textarea.ans { min-height: 70px; }
.rd { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.rd:first-child { border-top: 0; }
.rd .top1 { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.rd .note { font-family: var(--f-display); font-size: 16px; }
.sheet.tall { min-height: 70vh; min-height: 70dvh; }
.moods.sm .md i { width: 32px; height: 32px; }

/* sessions */
.srow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.srow:first-child { border-top: 0; }
.srow .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.srow .tx b { font-size: 15px; }
.srow .tx span { font-size: 12.5px; color: var(--mute); }
.play { width: 40px; height: 40px; border-radius: 50%; background: var(--card2); display: grid; place-items: center; flex: none; }
.play svg { width: 14px; height: 14px; fill: var(--fg); }
.play.soon { opacity: .4; }
.play.kh { box-shadow: inset 0 0 0 1.5px var(--gold); }
.tag.spicy { color: var(--need); box-shadow: inset 0 0 0 1px rgba(201, 138, 111, .45); }
.tag.gold { color: var(--gold); box-shadow: inset 0 0 0 1px rgba(212, 175, 55, .45); }
.orb { width: 200px; height: 200px; border-radius: 50%; align-self: center; margin: 6px 0;
  background: radial-gradient(circle, var(--mood5) 0 17%, rgba(236, 223, 174, .38) 18% 38%, rgba(183, 210, 199, .18) 39% 60%, rgba(149, 171, 204, .08) 61% 100%); }
.orb.playing { animation: breathe 8s ease-in-out infinite; }
.ctrl { display: flex; justify-content: center; align-items: center; gap: 30px; }
.ctrl .sk { font-size: 13px; color: var(--mute); font-weight: 600; width: 48px; height: 48px; border-radius: 50%; }
.ctrl .big { width: 66px; height: 66px; border-radius: 50%; background: var(--fg); display: grid; place-items: center; }
.ctrl .big svg { width: 22px; height: 22px; fill: var(--ink); }
input[type=range].seek { width: 100%; accent-color: var(--fg); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; }
.teleprompter { font-family: var(--f-display); font-size: 20px; line-height: 1.55; white-space: pre-wrap; background: var(--card); border-radius: 14px; padding: 16px; max-height: 42vh; overflow-y: auto; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--need); margin-right: 8px; animation: breathe 1.6s ease-in-out infinite; }
.rec-time { font-family: var(--f-display); font-size: 34px; text-align: center; font-variant-numeric: tabular-nums; }
textarea.script-in { min-height: 220px; font-size: 17px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input { flex: 1; min-width: 0; }

/* tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(14, 19, 32, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 8px max(8px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
.tabs .in { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--mute); padding: 2px 0; }
.tabs button.on { color: var(--fg); }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* bottom sheet */
.scrim { position: fixed; inset: 0; z-index: 1000; background: rgba(5, 8, 14, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--ink);
  border-radius: 22px 22px 0 0; box-shadow: 0 -1px 0 var(--line);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px; }
.grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); align-self: center; flex: none; }
.err { color: var(--bad); font-size: 13px; min-height: 0; }
.err:empty { display: none; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 22px + env(safe-area-inset-bottom, 0px)); z-index: 1100;
  background: var(--card2); color: var(--fg); padding: 10px 16px; border-radius: 999px; font-size: 13.5px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); max-width: calc(100% - 32px); text-align: center; }

/* gate */
.gate { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: calc(28px + env(safe-area-inset-top, 0px)) max(22px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(22px, env(safe-area-inset-left, 0px));
  background: radial-gradient(120% 60% at 50% 0%, #1b2440 0%, var(--ink) 70%); }
.logo { font-family: var(--f-display); font-size: 18px; display: flex; align-items: center; gap: 9px; }
.logo img { width: 26px; height: 26px; border-radius: 7px; }
.loading { flex: 1; display: grid; place-items: center; }
.loading i { width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle, var(--mood5) 0 26%, rgba(236, 223, 174, .25) 27% 58%, transparent 60%); animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(.82); opacity: .7; } 50% { transform: scale(1); opacity: 1; } }
