/* «Делим» — общий счёт, разрезанный пополам. Знак — круг из двух половин: одна залита, другая обведена.
   Тёплая бумага, чернила, одно красное — цвет того, кто должен перевести. Шрифт Rubik: округлый, дружелюбный, цифры ровные. */
@font-face { font-family: "Rubik"; font-weight: 400; font-display: swap; src: url(/assets/fonts/rubik-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Rubik"; font-weight: 400; font-display: swap; src: url(/assets/fonts/rubik-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD, U+2212, U+2192; }
@font-face { font-family: "Rubik"; font-weight: 600; font-display: swap; src: url(/assets/fonts/rubik-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Rubik"; font-weight: 600; font-display: swap; src: url(/assets/fonts/rubik-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20BD, U+2212, U+2192; }

:root {
  --paper: #fff6e9;
  --sheet: #fffdf8;
  --ink: #19130f;
  --ink-2: #57504a;
  --rule: rgba(25, 19, 15, 0.14);
  --red: #e8432b;
  --red-btn: #c4381f; /* та же краска темнее: белый текст на ней читается (контраст выше 4,5) */
  --red-ink: #b8301b;
  --green: #1f7a4a;
  --font: "Rubik", "Helvetica Neue", Arial, sans-serif;
  --pad: clamp(18px, 4vw, 48px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
h1, h2, h3, p, ol, ul, fieldset, legend, table { margin: 0; padding: 0; }
ol, ul { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: var(--red-ink); text-underline-offset: 0.18em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { position: absolute; top: 8px; left: 8px; z-index: 5; background: var(--sheet); padding: 8px 12px; }

.top, main, .foot { width: calc(100% - 2 * var(--pad)); max-width: 1160px; margin: 0 auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; padding: 20px 0 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 600 24px/1 var(--font); letter-spacing: -0.02em; min-height: 44px; }
.brand__mark { width: 30px; height: 30px; color: var(--red); }
.brand__mark path:last-child { stroke: var(--ink); }
.top__what { font-size: 15px; color: var(--ink-2); }

.hero { padding: clamp(28px, 6vw, 72px) 0 clamp(24px, 4vw, 40px); max-width: 48rem; }
.hero h1 { font: 600 clamp(40px, 7vw, 84px)/0.98 var(--font); letter-spacing: -0.04em; text-wrap: balance; }
.lead { margin-top: 18px; font-size: clamp(17px, 1.7vw, 21px); color: var(--ink-2); max-width: 40em; text-wrap: pretty; }
.note { margin-top: 16px; padding: 10px 14px; border-left: 4px solid var(--red); background: var(--sheet); font-size: 15px; }

/* Доска: слева — компания и траты, справа — переводы (на широком экране держатся на месте). */
.board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "group result" "spend result"; gap: 0 clamp(24px, 4vw, 56px); align-items: start; }
.pane--group { grid-area: group; }
.pane--spend { grid-area: spend; }
.pane--result { grid-area: result; position: sticky; top: 16px; background: var(--ink); color: var(--paper); padding: 24px clamp(18px, 2.4vw, 32px) 28px; }
.pane { padding: 24px 0 28px; border-top: 2px solid var(--ink); }
.pane.pane--result { border-top: 0; padding: 24px clamp(20px, 2.4vw, 32px) 28px; }
.pane h2 { display: flex; align-items: center; gap: 12px; font: 600 22px/1.2 var(--font); letter-spacing: -0.015em; margin-bottom: 18px; }
.step { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--red-btn); color: #fff; font-size: 15px; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, legend { font-size: 14px; color: var(--ink-2); }
input, select { min-height: 48px; padding: 10px 12px; border: 2px solid var(--ink); background: var(--sheet); border-radius: 0; width: 100%; font-size: 17px; }
select { -webkit-appearance: none; appearance: none; padding-right: 34px; background: var(--sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2319130f' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center; cursor: pointer; }
input::placeholder { color: #9a9088; }
input:focus, select:focus { outline: 0; box-shadow: 4px 4px 0 var(--red); }
.field--title { margin-bottom: 16px; }

.btn { min-height: 48px; padding: 0 20px; border: 2px solid var(--ink); background: var(--sheet); font-weight: 600; cursor: pointer; transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.btn:hover { transform: translate(-2px, -2px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: none; box-shadow: none; }
.btn--accent { background: var(--red-btn); border-color: var(--red-btn); color: #fff; }
.btn--accent:hover { box-shadow: 2px 2px 0 var(--ink); }
.pane--result .btn { border-color: var(--paper); background: transparent; color: var(--paper); }
.pane--result .btn--accent { background: var(--red-btn); border-color: var(--red-btn); }
.pane--result .btn:hover { box-shadow: 2px 2px 0 var(--paper); }
.linkbtn { background: none; border: 0; padding: 10px 0; color: inherit; text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; min-height: 44px; font-size: 15px; opacity: 0.8; }
.x { width: 44px; height: 44px; flex: none; border: 0; background: none; font-size: 24px; line-height: 1; color: var(--ink-2); cursor: pointer; }
.x:hover { color: var(--red-ink); }

/* Участники — строкой «кружок с буквой — имя». */
.people { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 14px; }
.person { display: inline-flex; align-items: center; gap: 8px; padding-right: 0; }
.person__dot { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--ink); font-weight: 600; font-size: 15px; }
.person__name { font-weight: 600; }
.person .x { width: 36px; height: 44px; margin-left: -6px; }
.people__empty { color: var(--ink-2); font-size: 15px; }
.add-person { display: flex; gap: 10px; align-items: flex-end; }
.add-person .field { flex: 1; }

.add-spend { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.8fr); gap: 14px; }
.field--payer, .between, .add-spend__go { grid-column: 1 / -1; }
.between__list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tick { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px 6px 10px; border: 2px solid var(--ink); background: var(--sheet); cursor: pointer; font-size: 16px; user-select: none; }
.tick input { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; min-height: 0; padding: 0; border: 2px solid var(--ink); background: #fff; display: grid; place-content: center; margin: 0; }
.tick input::after { content: ""; width: 9px; height: 5px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: translateY(-1px) rotate(-45deg); opacity: 0; }
.tick input:checked { background: var(--ink); }
.tick input:checked::after { opacity: 1; }
.tick:has(input:checked) { background: var(--ink); color: var(--paper); }
.tick:has(input:checked) input { border-color: var(--paper); background: var(--paper); }
.tick:has(input:checked) input::after { border-color: var(--ink); }
.tick:has(input:focus-visible) { outline: 3px solid var(--red); outline-offset: 2px; }
.add-spend__go { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hint { color: var(--red-ink); font-size: 15px; }

.spends { margin-top: 22px; border-top: 1px solid var(--rule); }
.spend { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); animation: drop 0.35s var(--ease); }
.spend__what { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.spend__what small { display: block; font-weight: 400; font-size: 14px; color: var(--ink-2); }
.spend__sum { font-weight: 600; white-space: nowrap; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

/* Переводы: от кого — стрелка — кому — сумма. Красным — тот, кто переводит. */
.pane--result h2 { color: var(--paper); }
.pane--result .step { background: var(--paper); color: var(--ink); }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid rgba(255, 246, 233, 0.25); }
.total span { font-size: 15px; opacity: 0.8; }
.total b { font-size: 22px; }
.transfers { margin: 8px 0 6px; }
.transfer { display: grid; grid-template-columns: auto 56px auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 14px 0; border-bottom: 1px solid rgba(255, 246, 233, 0.18); animation: drop 0.4s var(--ease) backwards; }
.transfer:nth-child(2) { animation-delay: 0.06s; }
.transfer:nth-child(3) { animation-delay: 0.12s; }
.transfer__from { color: #ff8a73; font-weight: 600; font-size: 19px; }
.transfer__to { font-weight: 600; font-size: 19px; }
.transfer__arrow { position: relative; height: 2px; background: currentColor; opacity: 0.85; }
.transfer__arrow i { position: absolute; right: 0; top: -5px; width: 12px; height: 12px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); }
.transfer__sum { justify-self: end; font-size: clamp(20px, 2vw, 26px); white-space: nowrap; }
.pane--result .empty { padding: 18px 0; opacity: 0.85; }
.more { margin-top: 14px; }
.more summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; text-decoration: underline; text-underline-offset: 0.2em; font-size: 15px; }
.balance { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 15px; }
.balance th, .balance td { padding: 8px 10px 8px 0; border-bottom: 1px solid rgba(255, 246, 233, 0.18); text-align: left; font-weight: 400; }
.balance thead th { font-size: 13px; opacity: 0.75; }
.balance tbody th { font-weight: 600; }
.balance .r { text-align: right; padding-right: 0; padding-left: 10px; white-space: nowrap; }
.balance .plus { color: #8fe0b4; }
.balance .minus { color: #ff8a73; }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.share-note { margin-top: 12px; font-size: 14px; opacity: 0.8; max-width: 34em; }
.pane--result .empty { font-size: 16px; }

.text { max-width: 46rem; margin: clamp(56px, 8vw, 96px) 0 0; }
.text h2 { font: 600 clamp(24px, 2.6vw, 30px)/1.2 var(--font); letter-spacing: -0.02em; margin-top: 40px; }
.text h2:first-child { margin-top: 0; }
.text h3 { font: 600 18px/1.35 var(--font); margin-top: 22px; }
.text p { margin-top: 10px; text-wrap: pretty; }

.foot { margin-top: 72px; padding: 22px 0 32px; border-top: 2px solid var(--ink); display: grid; gap: 10px; font-size: 14px; color: var(--ink-2); }
.foot__made a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: -10px 0; color: var(--ink); text-decoration: none; white-space: nowrap; }
.foot__made a:hover { text-decoration: underline; }
.foot__made svg { width: 16px; height: 16px; }

@media (max-width: 900px) {
  .board { grid-template-columns: minmax(0, 1fr); grid-template-areas: "group" "spend" "result"; }
  .pane.pane--result { position: static; margin: 8px calc(var(--pad) * -1) 0; padding-left: var(--pad); padding-right: var(--pad); }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .add-spend { grid-template-columns: minmax(0, 1fr); }
  .transfer { grid-template-columns: auto 36px minmax(0, 1fr); grid-template-areas: "from arrow to" "sum sum sum"; row-gap: 4px; }
  .transfer__from { grid-area: from; }
  .transfer__arrow { grid-area: arrow; }
  .transfer__to { grid-area: to; }
  .transfer__sum { grid-area: sum; justify-self: start; }
  .top__what { width: 100%; }
  .foot__made a { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .top, .foot, .hero, .pane--group, .pane--spend, .text, .btns, .share-note, .linkbtn { display: none !important; }
  .pane--result { position: static; background: #fff; color: #000; }
}
