:root {
  color-scheme: dark;
  --bg: #0d0d0f;
  --surface: #16161a;
  --surface-2: #1f1f24;
  --border: #26262c;
  --text: #f3f3f4;
  --muted: #8c8c95;
  --faint: #5a5a62;
  --accent: #c9f25c;
  --accent-soft: rgba(201, 242, 92, 0.14);
  --accent-ink: #0d0d0f;
  --radius: 20px;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 96px);
}
.screen.enter { animation: enter 0.28s ease; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.head { margin: 4px 4px 20px; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.title { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.hero { padding: 22px 20px 18px; position: relative; overflow: hidden; }
.hero::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -70px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(201, 242, 92, 0.2), transparent);
  pointer-events: none;
}
.label { color: var(--muted); font-size: 14px; }
.big { font-size: 46px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin-top: 6px; font-variant-numeric: tabular-nums; }
.accent { color: var(--accent); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

.section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
.section-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.count { color: var(--muted); font-weight: 500; margin-left: 8px; }
.link { color: var(--accent); font-size: 15px; font-weight: 600; }

.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 14px 16px; }
.row + .row { border-top: 1px solid var(--border); }
button.row:active { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; overflow-wrap: anywhere; transition: color 0.2s; }
.row-sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip { flex: none; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.hot { background: var(--accent-soft); color: var(--accent); }

.check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--faint); display: grid; place-items: center; transition: 0.2s; }
.check svg { width: 14px; height: 14px; color: var(--accent-ink); opacity: 0; transform: scale(0.4); transition: 0.2s; }
.row.checked .check { background: var(--accent); border-color: var(--accent); }
.row.checked .check svg { opacity: 1; transform: none; }
.row.checked .row-title { color: var(--muted); text-decoration: line-through; }
.row.leaving { animation: leave 0.3s ease 0.2s forwards; }
@keyframes leave { to { opacity: 0; transform: translateX(28px); } }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.total { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px; min-width: 0; }
.total span { color: var(--muted); font-size: 12px; }
.total b { display: block; font-size: 17px; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.total.main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.total.main span { color: rgba(13, 13, 15, 0.6); }
.day-head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 600; margin: 24px 6px 8px; }

.segment { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.segment button { padding: 10px; border-radius: 10px; font-weight: 600; color: var(--muted); text-align: center; transition: 0.2s; }
.segment button.on { background: var(--surface-2); color: var(--text); }

.empty { color: var(--muted); text-align: center; padding: 26px 16px; font-size: 15px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.locked { min-height: 70vh; display: grid; place-items: center; text-align: center; color: var(--muted); }
.locked b { display: block; color: var(--text); font-size: 20px; margin-bottom: 6px; }

.skeleton { height: 150px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton + .skeleton { margin-top: 12px; height: 220px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  z-index: 20;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 30px rgba(201, 242, 92, 0.28);
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.92); }
.fab svg { width: 26px; height: 26px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(13, 13, 15, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); font-size: 11px; font-weight: 600; transition: color 0.2s; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--text); }
.tab.active svg { color: var(--accent); }

.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); animation: fadein 0.2s; }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px calc(16px + var(--safe-bottom));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  animation: up 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 14px; }
.sheet h3 { font-size: 20px; margin-bottom: 12px; }
textarea { width: 100%; padding: 14px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 16px; resize: none; outline: none; }
textarea:focus { border-color: var(--accent); }
.hint { color: var(--muted); font-size: 13px; margin: 8px 4px 14px; }
.btn-accent { width: 100%; padding: 16px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px; text-align: center; }
.btn-accent:disabled { opacity: 0.6; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fadein { from { opacity: 0; } }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 90px);
  z-index: 40;
  max-width: 528px;
  margin: 0 auto;
  padding: 14px 16px;
  white-space: pre-line;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: fadein 0.2s;
}

/* --- приветствие и серия --- */
.greet-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.greet { color: var(--muted); font-size: 15px; font-weight: 500; }
.title.home { font-size: 28px; }
.pill { flex: none; margin-top: 2px; font-size: 13px; font-weight: 700; padding: 7px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }

/* --- графики трат --- */
.chart-card { margin-top: 16px; padding: 18px; }
.chart-title { font-size: 17px; font-weight: 700; }
.chart-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.chart-big { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.delta { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.delta.good { color: var(--accent); }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; height: 132px; margin-top: 18px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; text-align: center; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--border); }
.bar { width: 62%; max-width: 30px; border-radius: 4px 4px 0 0; background: var(--faint); transition: background 0.2s, height 0.4s ease; }
.bar.zero { height: 2px !important; border-radius: 1px; background: var(--border); }
.bar-col.on .bar:not(.zero) { background: var(--accent); }
.bar-label { font-size: 11px; font-weight: 600; color: var(--muted); }
.bar-col.on .bar-label { color: var(--text); }
.caption { margin-top: 12px; font-size: 14px; color: var(--muted); }
.caption b { color: var(--text); font-variant-numeric: tabular-nums; }
.grp { padding: 12px 0; }
.grp + .grp { border-top: 1px solid var(--border); }
.grp:last-child { padding-bottom: 0; }
.grp-top { display: flex; justify-content: space-between; gap: 12px; }
.grp-name { font-weight: 600; }
.grp-sum { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grp-pct { color: var(--muted); font-weight: 500; margin-left: 8px; }
.grp-track { height: 6px; margin-top: 8px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.grp-fill { height: 100%; border-radius: 3px; background: var(--accent); }

/* --- запись голоса и результат --- */
.rec { display: flex; flex-direction: column; align-items: center; padding: 6px 0 2px; }
.rec-status { color: var(--muted); font-size: 15px; }
.rec-timer { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0 12px; }
.wave { display: flex; gap: 4px; align-items: center; height: 56px; margin-bottom: 22px; }
.wave span { width: 4px; height: 100%; border-radius: 2px; background: var(--accent); transform: scaleY(0.08); transition: transform 0.08s linear; }
.rec-btn { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); animation: pulse 1.6s infinite; }
.rec-btn span { width: 24px; height: 24px; border-radius: 6px; background: var(--accent-ink); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 242, 92, 0.45); }
  70% { box-shadow: 0 0 0 18px rgba(201, 242, 92, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 242, 92, 0); }
}
.rec-hint { color: var(--faint); font-size: 13px; margin-top: 12px; }
.text-link { margin-top: 14px; padding: 8px; color: var(--muted); font-weight: 600; text-align: center; }
.busy { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 34px 0; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result-quote { color: var(--muted); font-size: 15px; margin: 2px 0 14px; padding-left: 12px; border-left: 2px solid var(--accent); }
.result-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; opacity: 0; animation: pop 0.35s ease forwards; }
.result-icon { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); font-size: 18px; }
.result-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.result-kind { display: block; color: var(--muted); font-size: 12px; }
.result-crossed { color: var(--accent); font-size: 14px; font-weight: 600; margin: 6px 2px 4px; opacity: 0; animation: pop 0.35s ease forwards; }
#result { margin-bottom: 14px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }

/* --- знакомство --- */
.onb { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; padding: 24px 24px calc(24px + var(--safe-bottom)); background: var(--bg); }
.onb-body { flex: 1; display: flex; align-items: center; }
.onb-slide { width: 100%; max-width: 420px; margin: 0 auto; text-align: center; animation: enter 0.35s ease; }
.onb-art { height: 210px; display: grid; place-items: center; margin-bottom: 28px; }
.onb h2 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; }
.onb p { color: var(--muted); font-size: 16px; max-width: 330px; margin: 0 auto; }
.onb-foot { width: 100%; max-width: 420px; margin: 0 auto; }
.onb-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 20px; }
.onb-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--border); transition: 0.25s; }
.onb-dots i.on { width: 20px; background: var(--accent); }
.btn-ghost { width: 100%; padding: 14px; margin-top: 6px; color: var(--muted); font-weight: 600; text-align: center; }
.art-mic { position: relative; width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); animation: pulse 1.8s infinite; }
.art-mic svg { width: 46px; height: 46px; }
.art-card { width: 240px; padding: 16px; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; }
.art-card .bars { height: 110px; margin-top: 0; }
.art-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.art-row + .art-row { border-top: 1px solid var(--border); }
.art-row .check { width: 20px; height: 20px; }
.art-row.checked { color: var(--muted); text-decoration: line-through; }
.art-row.checked .check { background: var(--accent); border-color: var(--accent); }
.art-row.checked .check svg { opacity: 1; transform: none; }

/* --- профиль: чем занимаешься --- */
.field { width: 100%; padding: 14px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 14px; outline: none; }
.field:focus { border-color: var(--accent); }
.job-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.job-chip { padding: 8px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; font-weight: 600; transition: 0.15s; }
.job-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.onb-form { width: 100%; max-width: 340px; margin: 24px auto 0; }
.onb-form .job-chips { justify-content: center; }
.who { margin-top: 4px; padding: 2px 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.job-card { display: block; width: 100%; padding: 18px; border-color: rgba(201, 242, 92, 0.35); }
.job-card-title { font-size: 17px; font-weight: 700; }
.job-card-text { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }

/* --- свайп и удержание для удаления --- */
.swipe { position: relative; overflow: hidden; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.swipe + .swipe { border-top: 1px solid var(--border); }
.swipe .row { position: relative; z-index: 1; background: var(--surface); transition: transform 0.25s ease, background 0.15s; }
.swipe.dragging .row { transition: none; }
.swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding: 0 20px; background: #3a1416; color: #ff6b6b; font-size: 14px; font-weight: 700; transition: background 0.15s, color 0.15s; }
.swipe[data-dir="right"] .swipe-bg { justify-content: flex-start; }
.swipe.armed .swipe-bg { background: #e5484d; color: #fff; }
.swipe.collapsing { transition: height 0.25s ease, opacity 0.25s ease; }

/* --- редактирование --- */
.btn-gap { margin-top: 14px; }
.btn-danger { width: 100%; padding: 14px; margin-top: 6px; color: #ff6b6b; font-weight: 600; text-align: center; }
.edit-item { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.edit-item .field { flex: 1; min-width: 0; }
.edit-item .amount-field { flex: 0 0 104px; text-align: right; }
.edit-remove { flex: none; width: 32px; height: 44px; color: var(--muted); font-size: 22px; text-align: center; }
#edit-add-item { display: block; width: 100%; margin: 2px 0 6px; color: var(--accent); }
.edit-total { min-height: 20px; margin: 2px 2px 12px; color: var(--muted); font-size: 14px; text-align: right; }
.edit-total b { color: var(--text); font-variant-numeric: tabular-nums; }

/* --- дела и встречи --- */
.task-row { padding: 0 16px 0 4px; gap: 4px; }
.check-btn { flex: none; width: 46px; height: 54px; display: grid; place-items: center; }
.row-tap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 14px 0; text-align: left; }
.meet-icon { flex: none; width: 46px; display: grid; place-items: center; font-size: 18px; }
.chip.late { background: rgba(255, 100, 100, 0.14); color: #ff6b6b; }
.task-row.leaving { animation: leave 0.3s ease 0.25s forwards; }
.done-toggle { display: block; width: 100%; margin-top: 18px; padding: 14px; color: var(--muted); font-weight: 600; text-align: center; }
.edit-when { display: flex; gap: 8px; margin-top: 10px; }
.edit-when label { flex: 1; min-width: 0; }
.edit-when span { display: block; color: var(--muted); font-size: 12px; margin: 0 4px 4px; }
.edit-when .field { min-height: 48px; }
