@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/dmsans-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Sans'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/dmsans-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/fraunces-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/fraunces-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/fraunces-italic-latin-ext.woff2) format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Fraunces'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/fraunces-italic-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Tumšais izskats ir noklusējums; gaišo ieslēdz data-theme="light" (to uzliek app.js). */
:root {
  --bg: #1D1122;
  --ink: #F6F0F8;
  --muted: #A994B3;
  --line: #4A3552;
  --accent: #CDB7DB;
  --outline: #CDB7DB;
  --paid: #CDB7DB;
  --debt: #F2463D;
  --future: #6A5273;
  --btn-bg: #CDB7DB;
  --btn-ink: #1D1122;
  --surface: #33243A;
  --pick: #F6F0F8;
  --logo-filter: invert(1);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #F5F4F1;
  --ink: #17141A;
  --muted: #6B6570;
  --line: #D8D5DC;
  --accent: #6F3A7A;
  --outline: #17141A;
  --paid: #17141A;
  --debt: #C62828;
  --future: #B5B0BA;
  --btn-bg: #6F3A7A;
  --btn-ink: #FFFFFF;
  --surface: #E7E4E9;
  --pick: #6F3A7A;
  --logo-filter: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; } /* mērogošanas noapaļošana nedrīkst radīt sānu ritināšanu */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  transition: background-color 0.5s ease, color 0.5s ease;
}
#app {
  max-width: 420px;
  min-height: 100vh;
  min-height: calc(100dvh / var(--fit, 1)); /* --fit: skata samazinājums, skat. fit() */
  margin: 0 auto;
  padding: 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.label { font-size: 13px; font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.updated { margin-top: auto; padding-top: 8px; font-size: 12px; letter-spacing: 0.06em; color: var(--muted); text-align: center; }
.note { font-family: var(--serif); font-style: italic; font-size: 18px; line-height: 1.3; color: var(--muted); text-align: center; margin: 0; min-height: 74px; flex: none; }
.note span { display: block; }
.note .emoji { font-style: normal; font-size: 38px; line-height: 1.3; }
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 10; }
.confetti i { position: absolute; top: -24px; display: block; animation: krit 3s linear forwards; }
.confetti .c0 { background: var(--ink); }
.confetti .c1 { background: #8B3F9A; }
.confetti .c2 { background: #CDB7DB; }
.confetti .c3 { background: #E3B341; }

/* Logo */
.logo { width: 56px; align-self: center; flex: none; padding: 0; border: none; background: transparent; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.logo img { display: block; width: 100%; height: auto; pointer-events: none; filter: var(--logo-filter); }
.logo.flip { animation: apmet 0.6s ease-in-out; }
.logo.flip img { transition: filter 0s linear 0.3s; }

/* Deju aplis */
.ring { position: relative; width: min(312px, 100%); aspect-ratio: 1; align-self: center; flex: none; }
.ring.home { touch-action: pan-y; cursor: grab; margin-top: 10px; }.ring-spin { position: absolute; inset: 0; will-change: transform; }
.ring-pointer { position: absolute; left: 50%; top: -15px; margin-left: -7px; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 11px solid var(--ink); transform-origin: 50% 0; }
.ring.brake .ring-pointer { border-top-color: var(--debt); }
/* Spēles laikā parādnieku punkti nemirgo, lai sarkanos var skaidri redzēt. */
.ring.spinning .dot-btn span { animation: none; }
.dot { position: absolute; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; background: var(--paid); transition: background-color 0.5s ease; }
.dot.on { width: 22px; height: 22px; margin: -11px 0 0 -11px; background: var(--pick); }
.party .dot { animation: lec 1.6s ease-in-out infinite; }
.party-text { font-family: var(--serif); font-size: 28px; line-height: 1.15; max-width: 190px; }
.party-emoji { font-size: 46px; line-height: 1.25; }
.sparks { position: absolute; inset: 0; pointer-events: none; }
.spark { position: absolute; margin: -3px 0 0 -3px; animation: dzirkstele 0.8s cubic-bezier(0.1, 0.7, 0.3, 1) forwards; }
.spark.c0 { background: var(--ink); }
.spark.c1 { background: #8B3F9A; }
.spark.c2 { background: #CDB7DB; }
.spark.c3 { background: #E3B341; }
.dot-btn { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0; border: none; background: transparent; display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; }
.dot-btn span { display: block; width: 13px; height: 13px; background: var(--debt); animation: elpo 2.4s ease-in-out infinite; transition: width 0.2s ease, height 0.2s ease; }
.dot-btn[aria-pressed='true'] span { width: 22px; height: 22px; background: var(--pick); animation: none; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; pointer-events: none; text-align: center; }
.ring-center a, .ring-center button { pointer-events: auto; }
.pills { display: flex; gap: 8px; }
.pills .pill-link { padding: 0 14px; white-space: nowrap; }
.balance { font-family: var(--serif); font-size: 52px; line-height: 1; }
.ring-center .text-btn { align-self: center; min-height: 30px; font-size: 13px; }
button.pill-link { border: none; cursor: pointer; }
.pill-link.primary { background: var(--btn-bg); color: var(--btn-ink); }
.count { font-family: var(--serif); font-weight: 400; font-size: 128px; line-height: 1; color: var(--debt); }
.count.zero { color: var(--ink); }
.stack { display: block; max-width: 100%; }
.stack span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picked-name { font-family: var(--serif); font-size: 30px; line-height: 1.1; width: 214px; height: 66px; display: flex; flex-direction: column; justify-content: center; }
.picked-name.long { font-size: 24px; }
.picked-name.xlong { font-size: 19px; }
.picked-sum { font-family: var(--serif); font-size: 52px; line-height: 1; color: var(--debt); }
.picked-sum.zero { color: var(--ink); }
.ring-center .hit { color: var(--debt); font-weight: 600; }
.pill-link { display: inline-flex; align-items: center; height: 44px; padding: 0 22px; background: var(--surface); border-radius: 22px; text-decoration: none; font-size: 14px; font-weight: 500; }

/* Meklēšana un saraksti */
.field { display: flex; flex-direction: column; gap: 8px; }
.input { height: 52px; width: 100%; flex: none; padding: 0 2px; background: transparent; border: none; border-bottom: 1.5px solid var(--outline); border-radius: 0; font-size: 18px; appearance: none; -webkit-appearance: none; }
.input::placeholder { color: inherit; opacity: 0.6; }
.input::-webkit-search-decoration, .input::-webkit-search-cancel-button { -webkit-appearance: none; }
.input:focus-visible { outline: none; border-bottom-color: var(--accent); box-shadow: 0 1.5px 0 var(--accent); }
.list { display: flex; flex-direction: column; margin-top: 6px; }
.list .label { padding-bottom: 6px; }
.list .label.next { padding-top: 22px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.row .rank { font-family: var(--serif); font-style: italic; font-size: 20px; line-height: 1; color: var(--muted); width: 24px; flex: none; }
.row .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sum { font-family: var(--serif); font-size: 22px; line-height: 1; }
.save-row { display: flex; align-items: center; gap: 12px; padding: 2px 0 10px; }
.save-row .input { flex: 1; min-width: 0; height: 44px; }
.save-row .pill-link { flex: none; white-space: nowrap; }
.text-btn { align-self: flex-start; min-height: 44px; padding: 0; border: none; background: transparent; color: var(--accent); font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }

/* Cilvēka skats */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; letter-spacing: 0.06em; color: var(--muted); }
.icon-link { display: flex; align-items: center; width: 44px; height: 44px; color: var(--ink); }
.topbar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Vārda blokam ir nemainīgs augstums: īss vārds, garš vārds vai divas rindas — pārējais nekust. */
.name { margin: 0; height: 72px; flex: none; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.1; text-align: center; }
.name .stack { width: 100%; }
.name .long { font-size: 26px; }
.name .xlong { font-size: 21px; }
.ring.months { width: min(270px, 100%); }
.m { position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 1.5px solid var(--future); background: transparent; }
.m.paid { background: var(--paid); border-color: var(--paid); }
.m.debt { background: var(--debt); border-color: var(--debt); animation: elpo 2.4s ease-in-out infinite; }
.m.due { border-color: var(--ink); animation: elpo 2.4s ease-in-out infinite; }
.m.off { opacity: 0.3; }
.m.free { border-color: var(--paid); } /* ar atlaidi: par šo mēnesi nav jāmaksā */
.m-label { position: absolute; width: 24px; margin: -8px 0 0 -12px; text-align: center; font-size: 12px; font-weight: 500; line-height: 16px; color: var(--muted); }
.amount { display: flex; align-items: baseline; gap: 8px; font-family: var(--serif); font-weight: 400; line-height: 1; }
.amount .n { font-size: 104px; font-variant-numeric: tabular-nums; }
.stepper .amount { min-width: 190px; justify-content: center; }
.amount .e { font-size: 40px; }
.amount.debt { color: var(--debt); }
.all-paid { font-family: var(--serif); font-size: 26px; line-height: 1.15; max-width: 130px; }
.options { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 10px; }
.warn { margin: 0; font-size: 14px; line-height: 1.45; min-height: 61px; } /* 3 rindas, lai garākais teksts neizstumj pārējo */
.warn strong { font-weight: 600; color: var(--accent); white-space: nowrap; }
.btn { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 58px; padding: 8px 24px; border: none; border-radius: 29px; background: var(--surface); text-decoration: none; font-weight: 500; transition: background-color 0.5s ease; }
.btn.primary { background: var(--btn-bg); color: var(--btn-ink); font-weight: 600; }
.btn .what { display: flex; flex-direction: column; line-height: 1.2; }
.btn .what small { font-size: 12px; font-weight: 400; color: var(--accent); }
.btn .price { display: flex; align-items: baseline; gap: 10px; font-family: var(--serif); font-size: 24px; line-height: 1; white-space: nowrap; }
.btn .price s { font-size: 18px; color: var(--muted); }
/* Uz krāsainās pogas mazie teksti ņem pogas tintes krāsu, citādi tie saplūst ar fonu. */
.btn.primary .what small { color: inherit; opacity: 0.75; }
.btn.primary .price s { color: inherit; opacity: 0.6; }
.more-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; padding: 10px 0 0; font-size: 14px; }
.more-links a { color: var(--accent); padding: 4px 0; }

/* Maksāšana */
.title { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.1; text-align: center; }
.stepper { display: flex; align-items: center; justify-content: space-between; }
.round { width: 56px; height: 56px; padding: 0; border: none; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; }
.round:disabled { opacity: 0.3; cursor: default; }
.month-row { display: flex; justify-content: center; gap: 12px; }
.month-row div { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 24px; font-size: 12px; font-weight: 500; color: var(--muted); }
.month-row i { display: block; width: 20px; height: 20px; border: 1.5px solid var(--future); }
.month-row .on { color: var(--ink); }
.month-row .on i { background: var(--paid); border-color: var(--paid); }
.reqs { display: flex; flex-direction: column; margin-top: auto; padding-top: 10px; }
.reqs .label { padding-bottom: 8px; }
.req { display: flex; justify-content: space-between; align-items: center; gap: 12px; height: 68px; border-top: 1px solid var(--line); }
.req:last-child { border-bottom: 1px solid var(--line); }
.req div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.req span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; line-height: 1.25; }
.req small { font-size: 12px; color: var(--muted); }
.icon-btn { width: 44px; height: 44px; flex: none; padding: 0; border: none; background: transparent; color: var(--accent); display: flex; align-items: center; justify-content: center; }

/* Ieeja */
.gate { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.gate .logo { width: 84px; margin-bottom: 12px; }
.error { min-height: 20px; margin: 0; font-size: 14px; color: var(--debt); text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@keyframes lec { 0%, 60%, 100% { transform: scale(1); } 30% { transform: scale(1.9); } }
@keyframes dzirkstele { 65% { opacity: 1; } to { transform: translate(var(--dx), var(--dy)) rotate(120deg) scale(0.4); opacity: 0; } }
@keyframes krit { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes elpo { 50% { opacity: 0.3; } }
@keyframes apmet { 0% { transform: scaleX(1); } 50% { transform: scaleX(0); } 100% { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
