:root {
  --void: #080b1f;
  --ink: #e7ecff;
  --dim: #8a93c2;
  --faint: #4b5285;
  --cyan: #6ef2ff;
  --violet: #b494ff;
  --gold: #ffc46b;
  --rose: #ff7aa8;
  --mint: #78e8a8;
  --glass: rgb(20 24 58 / .42);
  --glass-hi: rgb(150 170 255 / .14);
  --edge: rgb(160 180 255 / .16);
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--void);
  color: var(--ink);
  font: 16px/1.45 "Space Grotesk", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
html, body, .stage { overflow-x: clip; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.dim { color: var(--dim); }

#bg, #fx { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#bg { z-index: 0; }
#fx { z-index: 60; pointer-events: none; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  background: linear-gradient(var(--void) 10%, transparent);
}
.sig { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.sig b { font-weight: 500; color: var(--ink); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: blink 2.4s ease-in-out infinite; }
.locked .pulse-dot { background: var(--rose); box-shadow: 0 0 10px var(--rose); }
@keyframes blink { 50% { opacity: .35; } }

.tabs { display: flex; gap: 2px; position: relative; }
.tabs button {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim);
  padding: 6px 9px; border-radius: 8px; transition: color .25s, background .25s, text-shadow .25s;
}
.tabs button.active { color: var(--ink); background: var(--glass-hi); text-shadow: 0 0 12px var(--cyan); }
.gear { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--dim); transition: color .2s, transform .6s cubic-bezier(.2, .8, .2, 1); }
.gear svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.gear:hover, .gear.on { color: var(--ink); transform: rotate(90deg); }
.locked .tabs, .locked .gear { visibility: hidden; }

/* ---------- Stage ---------- */
.stage {
  position: relative; z-index: 10;
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 56px) 18px calc(env(safe-area-inset-bottom) + 110px);
}
.core { min-height: calc(100dvh - 170px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }

.orb-wrap { position: relative; width: min(76vw, 340px); aspect-ratio: 1; display: grid; place-items: center; }
#orb { position: absolute; width: 150%; height: 150%; left: -25%; top: -25%; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; }
.ring .track { stroke: rgb(160 180 255 / .1); stroke-width: .6; }
.ring .prog {
  stroke: url(#rg); stroke-width: 1.6; stroke-linecap: round;
  stroke-dasharray: 603.2; stroke-dashoffset: 603.2;
  filter: drop-shadow(0 0 4px rgb(110 242 255 / .8));
  transition: stroke-dashoffset 1.4s cubic-bezier(.2, .8, .2, 1);
}
.ring .ticks line { stroke: rgb(160 180 255 / .22); stroke-width: .5; }
.ring .ticks line.major { stroke: rgb(160 180 255 / .45); }
.ring .ticks { transform-origin: 100px 100px; animation: spin 120s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.readout { position: relative; text-align: center; pointer-events: none; }
.cap { font-family: var(--mono); font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--dim); }
.num {
  font-size: clamp(44px, 13vw, 64px); font-weight: 600; letter-spacing: -.03em; line-height: 1.05; margin: 4px 0 2px;
  background: linear-gradient(180deg, #fff 30%, #b9c4ff); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgb(180 160 255 / .35);
}
.num .cur { font-weight: 400; opacity: .55; margin-left: .12em; font-size: .6em; }
.sub { font-family: var(--mono); font-size: 12px; color: var(--dim); letter-spacing: .04em; }
.sub b { color: var(--ink); font-weight: 500; }

.voice { width: 100%; min-height: 3.2em; display: flex; gap: 10px; align-items: baseline; padding: 0 4px; }
.who { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; color: var(--cyan); text-shadow: 0 0 10px rgb(110 242 255 / .6); flex: none; }
#say { margin: 0; font-size: 17px; line-height: 1.45; color: var(--ink); }
#say .caret { display: inline-block; width: .5em; height: 1.05em; vertical-align: -.15em; margin-left: 2px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); animation: blink 1s steps(1) infinite; }
#say em { font-style: normal; color: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em;
  padding: 8px 13px; border-radius: 999px; color: var(--ink);
  background: var(--glass); border: 1px solid var(--edge);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: border-color .2s, box-shadow .2s, transform .12s;
  animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 60ms);
}
.chip:hover { border-color: rgb(110 242 255 / .5); box-shadow: 0 0 18px rgb(110 242 255 / .18); }
.chip:active { transform: scale(.95); }
.chip.gold { border-color: rgb(255 196 107 / .45); color: var(--gold); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } }

/* ---------- Panels ---------- */
.panel { margin-top: 44px; }
.panel h3, .settings h3 {
  display: flex; align-items: center; gap: 12px; margin: 0 0 14px;
  font: 500 11px/1 var(--mono); letter-spacing: .3em; color: var(--dim);
}
.panel h3 i, .settings h3 i { flex: 1; height: 1px; background: linear-gradient(90deg, var(--edge), transparent); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: linear-gradient(var(--violet), transparent); opacity: .4; }
.t-day { font: 500 10px/1 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--faint); margin: 20px 0 8px -18px; padding-left: 18px; }
.t-day:first-child { margin-top: 0; }
.node {
  position: relative; border-radius: 14px; margin: 0 0 6px -8px; padding: 10px 10px 10px 8px; cursor: pointer;
  transition: background .25s, box-shadow .25s;
  animation: rise .6s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 45ms);
}
.node::before {
  content: ""; position: absolute; left: -10px; top: 18px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--c); box-shadow: 0 0 10px var(--c);
}
.node.income { --c: var(--cyan); }
.node.expense { --c: var(--rose); }
.node.donation { --c: var(--gold); }
.node:hover, .node.open { background: var(--glass); box-shadow: inset 0 0 0 1px var(--edge); }
.n-row { display: flex; align-items: baseline; gap: 10px; }
.n-main { flex: 1; min-width: 0; }
.n-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n-sub { font: 400 11px/1.4 var(--mono); color: var(--dim); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n-sum { font-weight: 500; white-space: nowrap; color: var(--c); text-shadow: 0 0 14px color-mix(in srgb, var(--c) 45%, transparent); }
.node.expense .n-sum { color: var(--ink); opacity: .75; text-shadow: none; }

.edit { display: grid; gap: 10px; margin-top: 12px; animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; cursor: default; }
.edit .kinds { display: flex; gap: 6px; }
.edit .kinds button { flex: 1; font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; padding: 9px 0; border-radius: 9px; color: var(--dim); border: 1px solid var(--edge); }
.edit .kinds button.on { color: var(--ink); border-color: var(--c); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 30%, transparent); }
.edit input {
  width: 100%; min-width: 0; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--edge);
  background: rgb(8 11 31 / .55); outline: none; font-size: 16px;
}
.edit input:focus { border-color: rgb(110 242 255 / .55); box-shadow: 0 0 0 3px rgb(110 242 255 / .1); }
.edit .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit .acts { display: flex; justify-content: space-between; align-items: center; }
.edit .save { font: 500 12px/1 var(--mono); letter-spacing: .14em; padding: 11px 18px; border-radius: 10px; color: var(--void); background: linear-gradient(90deg, var(--cyan), var(--violet)); box-shadow: 0 0 20px rgb(110 242 255 / .3); }
.edit .del { font: 500 12px/1 var(--mono); letter-spacing: .14em; color: var(--rose); padding: 11px 4px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-bottom: 20px; position: relative; }
.bar { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.bar .due { position: absolute; bottom: 0; width: 100%; border: 1px solid rgb(180 148 255 / .35); border-bottom: 0; border-radius: 4px 4px 0 0; }
.bar .given { position: relative; width: 100%; border-radius: 4px 4px 0 0; background: linear-gradient(var(--gold), rgb(255 196 107 / .15)); box-shadow: 0 0 14px rgb(255 196 107 / .35); transform-origin: bottom; animation: grow .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 50ms); }
.bar .lbl { position: absolute; bottom: -18px; font: 400 9px/1 var(--mono); color: var(--faint); white-space: nowrap; }
@keyframes grow { from { transform: scaleY(0); } }
.legend { font: 400 11px/1 var(--mono); color: var(--dim); display: flex; gap: 8px; align-items: center; margin: 10px 0 0; }
.legend span { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.l-due { border: 1px solid rgb(180 148 255 / .6); }
.l-given { background: var(--gold); margin-left: 10px; }

/* ---------- Command bar ---------- */
.cmd {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: min(560px, calc(100% - 24px));
  display: flex; align-items: center; gap: 6px; padding: 6px;
  border-radius: 20px; background: rgb(16 20 52 / .62);
  border: 1px solid var(--edge);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 10px 40px rgb(0 0 0 / .45), inset 0 1px 0 rgb(255 255 255 / .06);
  transition: border-color .3s, box-shadow .3s;
}
.cmd:focus-within { border-color: rgb(110 242 255 / .4); box-shadow: 0 10px 40px rgb(0 0 0 / .45), 0 0 30px rgb(110 242 255 / .12), inset 0 1px 0 rgb(255 255 255 / .06); }
.cmd::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--a, 0deg), transparent 0 70%, var(--cyan) 80%, var(--violet) 88%, transparent 96%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .4s;
}
.cmd.thinking::before { opacity: 1; animation: orbit 1.6s linear infinite; }
@property --a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes orbit { to { --a: 360deg; } }
.field { position: relative; flex: 1; min-width: 0; }
.field input { width: 100%; border: 0; outline: none; background: none; font-size: 16px; padding: 10px 8px; caret-color: var(--cyan); }
.ph {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%); pointer-events: none;
  color: var(--faint); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 8px);
  transition: opacity .35s, filter .35s;
}
.ph.swap { opacity: 0; filter: blur(4px); }
.field.has .ph { display: none; }
.mic, .send { width: 42px; height: 42px; flex: none; border-radius: 14px; display: grid; place-items: center; color: var(--dim); transition: color .2s, background .2s, transform .12s; }
.mic svg, .send svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.send { color: var(--void); background: linear-gradient(135deg, var(--cyan), var(--violet)); box-shadow: 0 0 18px rgb(110 242 255 / .3); }
.send:active, .mic:active { transform: scale(.92); }
.mic.live { color: var(--mint); background: rgb(120 232 168 / .14); animation: blink 1s ease-in-out infinite; }
.send.ready { animation: ready 1.4s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 0 0 6px rgb(110 242 255 / .18), 0 0 28px rgb(110 242 255 / .55); } }

/* ---------- Settings ---------- */
.settings {
  position: fixed; z-index: 35; top: calc(env(safe-area-inset-top) + 54px); right: 14px; width: min(320px, calc(100% - 28px));
  padding: 16px; border-radius: 18px; background: rgb(16 20 52 / .78); border: 1px solid var(--edge);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); box-shadow: 0 20px 60px rgb(0 0 0 / .5);
  animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; transform-origin: top right;
}
.set-row { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 12px 2px; border-top: 1px solid rgb(160 180 255 / .08); font-size: 15px; text-align: left; }
.set-row:first-of-type { border-top: 0; }
.set-row input { width: 46px; text-align: right; border: 0; background: none; outline: none; font-weight: 600; color: var(--cyan); }
.set-row.danger { color: var(--rose); }

/* ---------- Meditation ---------- */
.meditation { position: fixed; inset: 0; z-index: 50; background: radial-gradient(ellipse at 50% 100%, #1c1440, #05061a 70%); display: grid; place-items: center; animation: fade 1.2s ease both; cursor: pointer; }
.meditation canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.med-text { position: relative; text-align: center; padding: 24px; max-width: 520px; }
.med-cap { font: 500 11px/1 var(--mono); letter-spacing: .4em; color: var(--gold); text-shadow: 0 0 14px rgb(255 196 107 / .6); }
.med-line { font-size: 24px; line-height: 1.4; min-height: 3em; transition: opacity 1.2s, filter 1.2s; }
.med-line.out { opacity: 0; filter: blur(8px); }
.med-hint { font: 400 11px/1 var(--mono); color: var(--faint); letter-spacing: .2em; margin-top: 30px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Locked ---------- */
.locked .panel { display: none; }

@media (max-width: 380px) {
  .hud { padding-left: 12px; padding-right: 12px; }
  .tabs button { padding: 6px 6px; letter-spacing: .06em; }
  .sig .dim { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}

/* Шар как кнопка микрофона */
.orb-wrap { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; transition: transform .25s cubic-bezier(.2, .8, .2, 1); outline: none; }
.orb-wrap:active { transform: scale(.97); }
.locked .orb-wrap { cursor: default; }
.listening .cap { color: var(--mint); text-shadow: 0 0 12px rgb(120 232 168 / .6); animation: blink 1.4s ease-in-out infinite; }
.listening .ring .prog { stroke-dashoffset: 0 !important; stroke: var(--mint); filter: drop-shadow(0 0 6px rgb(120 232 168 / .9)); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; } }
