:root {
  color-scheme: light;
  --bg: #f8f7f3;
  --ink: #141512;
  --soft: #3d3f39;
  --muted: #8e8f87;
  --line: #e9e8e1;
  --card: #ffffff;
  --green: #1fa35b;        /* насыщенный «долларовый» зелёный */
  --green-soft: #daf2e3;
  --green-deep: #13773f;
  --on-green: #ffffff;
  --shadow: 0 1px 2px rgba(20,21,18,.04), 0 12px 40px -12px rgba(20,21,18,.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { background: var(--bg); color: var(--ink); }
body {
  font: 17px/1.65 Inter, system-ui, sans-serif; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background-image: radial-gradient(60vw 40vw at 85% -10%, color-mix(in srgb, var(--green) 22%, transparent), transparent 70%);
  background-repeat: no-repeat; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 56px); }
.display { font-family: Unbounded, Inter, sans-serif; letter-spacing: -0.035em; line-height: 1; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
#view > * > * { animation: rise .6s cubic-bezier(.2,.8,.2,1) both; }
#view > * > *:nth-child(2) { animation-delay: .04s; } #view > * > *:nth-child(3) { animation-delay: .08s; }
#view > * > *:nth-child(4) { animation-delay: .12s; } #view > * > *:nth-child(5) { animation-delay: .16s; }
#view > * > *:nth-child(n+6) { animation-delay: .2s; }

/* Шапка */
header { padding: clamp(10px, 2.2vh, 24px) 0; }
header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo { font-family: Unbounded, sans-serif; font-weight: 600; font-size: 21px; text-decoration: none; letter-spacing: -0.04em; white-space: nowrap; }
.logo b { color: var(--green); }
nav { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
nav a, nav button { background: none; border: 0; cursor: pointer; text-decoration: none; font-weight: 500; font-size: 15px; color: var(--soft); padding: 9px 16px; border-radius: 999px; transition: background .2s, color .2s; white-space: nowrap; }
nav a:hover, nav button:hover { background: var(--line); color: var(--ink); }
nav .cta { background: var(--ink); color: var(--bg); }
nav .cta:hover { background: var(--green); color: var(--on-green); }

main { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: clamp(12px, 3vh, 40px) 0; }

/* Долг */
.debt { max-width: 860px; margin: 0 auto; text-align: center; }
.meta { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 6px 16px 6px 6px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.meta .ava { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: var(--green-deep); font-weight: 600; font-size: 13px; }
.meta b { color: var(--ink); font-weight: 500; }
.helpnote { background: var(--green-soft); box-shadow: none; }
.helpnote .ava { background: var(--green); color: var(--on-green); }
.helpnote span:last-child { color: var(--green-deep); }
.amount { font-weight: 500; font-size: clamp(44px, min(13vw, 14vh), 176px); margin: clamp(12px, 3vh, 32px) 0 6px; white-space: nowrap; }
.amount .cur { color: var(--green); font-weight: 400; }
.of { color: var(--muted); font-size: clamp(15px, 1.6vw, 18px); }
.bar { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; margin: clamp(14px, 3vh, 28px) auto 10px; max-width: 520px; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width 1.1s cubic-bezier(.2,.8,.2,1); }
.barnote { color: var(--muted); font-size: 14px; }
.barnote span + span:not(:empty)::before { content: " · "; }
.title { font-weight: 500; font-size: clamp(26px, 3.6vw, 44px); line-height: 1.15; margin: clamp(20px, 5vh, 56px) auto clamp(8px, 1.6vh, 16px); max-width: 22ch; }
.story { font-size: clamp(16px, 1.5vw, 19px); line-height: 1.6; max-width: 48ch; margin: 0 auto; color: var(--soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.story.open { -webkit-line-clamp: unset; }

.pay { margin: clamp(16px, 4vh, 48px) auto 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 10px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); width: fit-content; max-width: 100%; }
.chip, .input-sum, .btn { height: 52px; border-radius: 999px; font-weight: 500; font-size: 16px; }
.chip { padding: 0 20px; border: 0; background: var(--bg); cursor: pointer; transition: background .2s, color .2s; }
.chip:hover { background: var(--line); }
.chip.on { background: var(--green-soft); color: var(--green-deep); }
.input-sum { width: 140px; padding: 0 20px; border: 0; background: var(--bg); outline: none; transition: box-shadow .2s; }
.input-sum:focus { box-shadow: inset 0 0 0 1.5px var(--green); }
.btn { padding: 0 30px; border: 0; cursor: pointer; background: var(--green); color: var(--on-green); font-weight: 600; transition: transform .15s, filter .2s; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.mine { margin-top: clamp(16px, 4vh, 48px); color: var(--muted); }

.flip { margin: clamp(14px, 3.5vh, 40px) auto 0; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.flip button { background: none; border: 1px solid var(--line); cursor: pointer; font-weight: 500; font-size: 16px; color: var(--soft); padding: 14px 26px; border-radius: 999px; transition: border-color .2s, color .2s, background .2s; }
.flip button:hover { border-color: var(--ink); color: var(--ink); }
.flip button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.flip button.primary:hover { background: var(--green); border-color: var(--green); color: var(--on-green); }
.hint { display: block; margin-top: 12px; color: var(--muted); font-size: 12px; letter-spacing: .04em; }
kbd { font: inherit; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 120px); background: var(--ink); color: var(--bg); padding: 14px 24px; border-radius: 999px; font-weight: 500; font-size: 15px; transition: transform .35s cubic-bezier(.2,.8,.2,1); z-index: 10; max-width: calc(100% - 40px); text-align: center; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); }

/* Формы */
.narrow { max-width: 480px; margin: 0 auto; }
.page-h { font-weight: 500; font-size: clamp(40px, 7vw, 80px); margin-bottom: 18px; }
.page-h em { font-style: normal; color: var(--green); }
.lead { font-size: clamp(17px, 1.6vw, 19px); color: var(--muted); max-width: 38ch; margin-bottom: 48px; }
form { display: grid; gap: 20px; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.field { width: 100%; padding: 17px 20px; border-radius: 18px; border: 0; background: var(--card); box-shadow: var(--shadow); outline: none; font-size: 17px; color: var(--ink); transition: box-shadow .2s; }
.field::placeholder { color: var(--muted); opacity: .7; }
.field:focus { box-shadow: 0 0 0 1.5px var(--green), var(--shadow); }
textarea.field { min-height: 150px; resize: vertical; line-height: 1.6; }
.field.big { font-family: Unbounded, sans-serif; font-weight: 500; font-size: 30px; letter-spacing: -0.03em; }
.err { color: #c0392b; font-size: 15px; min-height: 1.4em; margin-bottom: -8px; }
form .btn { height: 58px; margin-top: 4px; }
.alt { color: var(--muted); text-align: center; font-size: 15px; }
.alt a { color: var(--green-deep); text-decoration: none; }
.steps { display: flex; gap: 8px; margin-bottom: 40px; }
.steps span { padding: 6px 14px; border-radius: 999px; background: var(--line); font-size: 13px; font-weight: 500; color: var(--muted); }
.steps span.on { background: var(--ink); color: var(--bg); }
.steps span.done { background: var(--green-soft); color: var(--green-deep); }


/* Кабинет */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 40px 0 64px; }
.stat { background: var(--card); border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.stat b { display: block; font-family: Unbounded, sans-serif; font-weight: 500; font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.035em; margin-bottom: 6px; }
.stat span { color: var(--muted); font-size: 14px; }
.list { display: grid; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 16px 24px; padding: 24px 28px; border-radius: 24px; background: var(--card); box-shadow: var(--shadow); text-decoration: none; transition: transform .2s; }
.row:hover { transform: translateY(-2px); }
.row h3 { font-weight: 500; font-size: 19px; }
.row .sum { font-family: Unbounded, sans-serif; font-weight: 500; font-size: 19px; text-align: right; letter-spacing: -0.03em; }
.row .bar { grid-column: 1 / -1; margin: 0; max-width: none; }
.section-h { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 16px; }

.empty { text-align: center; padding: 8vh 0; }
.empty .lead { margin: 0 auto 40px; }
.zero { color: var(--green); }
footer { padding: clamp(12px, 2.5vh, 28px) 0; color: var(--muted); font-size: 13px; }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
body.on-debt footer { display: none; }
@media (max-height: 760px) { .hint { display: none; } }
@media (max-height: 700px) { .story { -webkit-line-clamp: 2; } .amount { margin-top: 10px; } .bar { margin-top: 12px; } .title { margin-top: 18px; } .pay { margin-top: 16px; } .flip { margin-top: 14px; } main { padding: 6px 0; } .title { font-size: clamp(22px, 3.2vw, 36px); } }
@media (max-width: 600px) {
  .hint { display: none; }
  nav a:first-child:not(.cta) { display: none; }
  nav a, nav button { padding: 8px 12px; }
  .pay { border-radius: 28px; padding: 8px; gap: 6px; }
  .chip, .input-sum, .btn { height: 46px; }
  .chip { padding: 0 14px; }
  .flip button { padding: 12px 18px; font-size: 15px; }
  footer { display: none; }
  .input-sum { flex: 1; min-width: 120px; }
  footer .wrap { justify-content: center; text-align: center; }
}

/* Без inline-стилей (строгий CSP) */
.amount.mid { font-size: clamp(40px, 8vw, 96px); }
.center { text-align: center; margin-left: auto; margin-right: auto; }
.lead.center { margin-bottom: 32px; }
.helpnote-guest { margin-top: 10px; color: var(--muted); font-size: 13px; }

/* Окно входа */
dialog#auth { margin: auto; border: 0; padding: 0; background: var(--card); color: var(--ink); border-radius: 28px; width: min(440px, calc(100% - 32px)); box-shadow: 0 30px 80px -20px rgba(0,0,0,.35); }
dialog#auth::backdrop { background: rgba(14,15,13,.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog#auth[open] { animation: rise .35s cubic-bezier(.2,.8,.2,1); }
.auth-in { padding: 28px clamp(20px, 5vw, 32px) 28px; position: relative; }
.auth-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg); cursor: pointer; font-size: 18px; color: var(--muted); }
.auth-close:hover { color: var(--ink); }
.auth-reason { color: var(--muted); font-size: 15px; margin: 2px 40px 20px 0; min-height: 1.2em; }
.auth-reason:empty { display: none; }
.auth-h { font-family: Unbounded, sans-serif; font-weight: 500; font-size: 28px; letter-spacing: -0.035em; margin-bottom: 8px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 999px; padding: 4px; margin-bottom: 22px; }
.tabs button { border: 0; background: none; border-radius: 999px; padding: 10px; font-weight: 500; font-size: 15px; color: var(--muted); cursor: pointer; transition: background .2s, color .2s; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
#authForm { gap: 14px; }
#authForm .field { box-shadow: none; background: var(--bg); }
#authForm .field:focus { box-shadow: 0 0 0 1.5px var(--green); }
#authForm .btn { height: 54px; }
.auth-hint { color: var(--muted); font-size: 13px; text-align: center; }
