/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light dark;

  --bg: light-dark(#f7f1e8, #15100d);
  --surface: light-dark(#fffdf8, #201913);
  --surface-2: light-dark(#f6eee2, #2a211a);
  --surface-3: light-dark(#efe4d4, #332820);
  --ink: light-dark(#2b211b, #f4ebe0);
  --ink-soft: light-dark(#5b4b40, #d9c9b8);
  --muted: light-dark(#8b7a6b, #a08c79);
  --line: light-dark(#e9dccb, #362b23);
  --line-2: light-dark(#dccbb4, #4a3b30);

  --accent: light-dark(#c2603c, #e08a62);
  --accent-strong: light-dark(#a94c2c, #f09a72);
  --accent-soft: light-dark(#fbe8dd, #3a2419);
  --sage: light-dark(#6f8462, #a3b78d);
  --sage-soft: light-dark(#e9efe2, #26301f);
  --rose: light-dark(#bd7a6d, #d99c8e);
  --gold: light-dark(#b98c46, #d3a76a);
  --danger: light-dark(#b34a3a, #e08a78);

  --cat-groceries: light-dark(#6f8462, #a3b78d);
  --cat-dining: light-dark(#c2603c, #e08a62);
  --cat-lodging: light-dark(#b98c46, #d3a76a);
  --cat-transport: light-dark(#5b6f8a, #9fb2cc);
  --cat-flights: light-dark(#bd7a6d, #d99c8e);
  --cat-activities: light-dark(#5f7fa6, #9db8d6);
  --cat-shopping: light-dark(#a97ab0, #cfa5d4);
  --cat-gifts: light-dark(#c07a92, #dfa3b6);
  --cat-health: light-dark(#a76a86, #d29ab4);
  --cat-fees: light-dark(#8a6f5a, #bca189);
  --cat-cash: light-dark(#5f8a7f, #93b8ad);
  --cat-other: light-dark(#9c8b7b, #8d7c6d);

  --card: light-dark(#2a1f19, #211811);
  --card-2: light-dark(#3b2b22, #2f2219);
  --on-card: #fdf7ee;
  --on-card-muted: rgba(253, 247, 238, 0.66);
  --on-card-pos: #a9dcb7;
  --on-card-neg: #f4a892;

  --glow-a: light-dark(rgba(194, 96, 60, 0.14), rgba(224, 138, 98, 0.1));
  --glow-b: light-dark(rgba(111, 132, 98, 0.16), rgba(163, 183, 141, 0.08));

  --shadow-sm: 0 1px 2px rgba(58, 38, 26, 0.05), 0 8px 22px -16px rgba(58, 38, 26, 0.4);
  --shadow-md: 0 2px 4px rgba(58, 38, 26, 0.04), 0 18px 40px -24px rgba(58, 38, 26, 0.55);
  --shadow-lg: 0 30px 60px -30px rgba(40, 24, 14, 0.6);

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    Georgia, "Times New Roman", serif;

  --ease: cubic-bezier(0.22, 0.8, 0.25, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* -------------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 88% -6%, var(--glow-a), transparent 62%),
    radial-gradient(760px 520px at -12% 8%, var(--glow-b), transparent 58%),
    radial-gradient(700px 500px at 50% 110%, var(--glow-b), transparent 65%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

button {
  font-family: inherit;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 16px;
}

svg {
  display: block;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  padding: 40px;
  text-align: center;
}

/* ------------------------------------------------------------------- shell */

.app {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding: 0 18px calc(126px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -18px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 10px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-card);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand span:last-child {
  font-weight: 500;
}

.brand i {
  font-style: normal;
  color: var(--accent);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.16s var(--ease), transform 0.16s var(--ease);
}

.icon-btn:hover {
  background: var(--surface);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn.spin svg {
  animation: spin 1.1s linear infinite;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--card-2);
  color: var(--on-card);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
}

/* -------------------------------------------------------------------- view */

.view {
  padding-top: 8px;
}

.view.view-enter {
  animation: view-in 0.28s var(--ease);
}

.view-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 10px 2px 18px;
}

.section {
  margin-top: 26px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
  margin-bottom: 8px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.section-head a,
.section-head button {
  border: 0;
  background: none;
  padding: 4px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

.section-head a:hover,
.section-head button:hover {
  color: var(--accent);
}

/* ------------------------------------------------------------ balance card */

.balance-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 120% at 88% -18%, rgba(224, 138, 98, 0.36), transparent 52%),
    radial-gradient(90% 90% at 0% 120%, rgba(163, 183, 141, 0.18), transparent 60%),
    linear-gradient(155deg, var(--card-2), var(--card) 62%);
  color: var(--on-card);
  box-shadow: var(--shadow-lg);
}

.balance-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.07);
  pointer-events: none;
}

.balance-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-card-muted);
}

.balance-label .dot {
  width: 6px;
  height: 6px;
}

.balance-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.balance-line .balance-label {
  flex: 1 1 auto;
  min-width: 0;
}

.balance-label-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-line .balance-amount {
  flex: 0 0 auto;
  margin-top: 0;
  font-size: clamp(24px, 7vw, 32px);
}

.balance-line .balance-amount.settled {
  font-size: clamp(18px, 5.2vw, 22px);
  letter-spacing: -0.01em;
}

.balance-amount {
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: clamp(42px, 12.5vw, 56px);
  line-height: 1;
  letter-spacing: -0.028em;
  font-variant-numeric: lining-nums tabular-nums;
}

.balance-amount.settled {
  font-size: clamp(30px, 8.6vw, 40px);
  letter-spacing: -0.02em;
}

/* --------------------------------------------------- multi-currency rows */

.balance-rows {
  display: flex;
  flex-direction: column;
}

.balance-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.balance-row + .balance-row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.balance-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.balance-row-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-card-muted);
}

.balance-row-label .dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
}

.balance-row-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-row-amount {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.balance-row-amount .cur-code {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  color: var(--on-card-muted);
}

.balance-row-amount svg {
  width: 14px;
  height: 14px;
  color: rgba(253, 247, 238, 0.34);
}

/* Direction colours, tuned for the dark card. */
.pos {
  color: var(--on-card-pos);
}

.neg {
  color: var(--on-card-neg);
}

.balance-card .dot.ok {
  background: var(--on-card-pos);
}

.balance-card .dot.err {
  background: var(--on-card-neg);
}

.balance-amount.pos {
  color: var(--on-card-pos);
}

.balance-amount.neg {
  color: var(--on-card-neg);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: transform 0.13s var(--ease), background 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}

.btn:active {
  transform: scale(0.965);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px -14px color-mix(in srgb, var(--accent) 85%, transparent);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.btn-soft {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-soft:hover {
  background: var(--surface-3);
}

.btn-quiet {
  background: transparent;
  color: var(--ink-soft);
}

.btn-quiet:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 9px 14px;
  font-size: 13px;
}

/* --------------------------------------------------------------- statistics */

.stat-card {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-sm);
}

.stat-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
}

.stat-head span {
  font-size: 12px;
  color: var(--muted);
}

/* --------------------------------------------------------------- quick add */

.quick-add-card {
  margin-top: 14px;
  padding: 12px 16px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s, box-shadow 0.16s;
}

.quick-add-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 9%, transparent), var(--shadow-sm);
}

.quick-add-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.quick-add-head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
}

.quick-add-head span {
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-align: right;
}

.quick-add-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.quick-amount {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(28px, 8vw, 34px);
  letter-spacing: -0.03em;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.quick-amount::placeholder {
  color: color-mix(in srgb, var(--muted) 55%, transparent);
}

.quick-add-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 9px;
}

.quick-desc {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 15px;
  outline: none;
}

.quick-desc::placeholder {
  color: var(--muted);
}

.quick-add-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 20px -12px color-mix(in srgb, var(--accent) 75%, transparent);
  transition: transform 0.16s var(--ease), background 0.16s;
}

.quick-add-btn svg {
  width: 21px;
  height: 21px;
}

.quick-add-btn:hover {
  background: var(--accent-strong);
}

.quick-add-btn:active {
  transform: scale(0.94);
}

/* ----------------------------------------------------------- trend chart */

.chart-card {
  overflow: hidden;
}

.chart-head {
  align-items: center;
  flex-wrap: wrap;
}

.chart-toggle {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.chart-toggle:hover .chart-title {
  color: var(--accent-strong);
}

.chart-caret {
  margin-left: auto;
  color: var(--muted);
}

.chart-caret svg {
  width: 17px;
  height: 17px;
  transition: transform 0.18s var(--ease);
}

.chart-card.is-open .chart-caret svg {
  transform: rotate(90deg);
}

.chart-card:not(.is-open) .chart-head {
  margin-bottom: 0;
}

.chart-heading {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.25;
}

.chart-sub {
  font-size: 12px;
  color: var(--muted);
}

.chart-switch {
  flex: 0 0 auto;
  width: auto;
}

.chart-head .seg.compact {
  width: auto;
}

.chart {
  margin-top: 4px;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 5px;
  height: 146px;
}

.chart-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  height: 100%;
}

.chart-slot {
  display: flex;
  align-items: flex-end;
  flex: 1;
  min-height: 0;
}

.chart-bar {
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  min-height: 3px;
  overflow: hidden;
  border-radius: 5px 5px 2px 2px;
  background: var(--surface-3);
  transition: height 0.4s var(--ease);
}

.chart-bar.is-empty {
  border-bottom: 2px dotted var(--line-2);
  border-radius: 0;
  background: transparent;
}

.chart-seg {
  display: block;
  width: 100%;
  min-height: 2px;
}

.chart-month {
  display: block;
  font-size: 9px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--muted);
}

.chart-col.is-now .chart-month {
  color: var(--ink);
  font-weight: 700;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.chart-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.chart-key i {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.chart-key span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-key strong {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- entries */

.entries {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.entry {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 10px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s var(--ease), transform 0.14s var(--ease);
}

.entry:hover {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.entry:active {
  transform: scale(0.992);
}

.entry-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink-soft);
}

.entry-icon svg {
  width: 20px;
  height: 20px;
}

.entry-main {
  min-width: 0;
  flex: 1 1 auto;
}

.entry-title {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-meta {
  display: block;
  margin-top: 1px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-side {
  flex: 0 0 auto;
  text-align: right;
}

.entry-amount {
  display: block;
  font-size: 14.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.entry-amount.credit {
  color: var(--sage);
}

.entry-sub {
  display: none;
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 520px) {
  .entry-sub {
    display: block;
  }
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------- tones */

.entry-icon.tone-sage {
  background: var(--sage-soft);
  color: var(--sage);
}

.entry-icon.tone-clay {
  background: var(--accent-soft);
  color: var(--accent);
}

.entry-icon.tone-gold {
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  color: var(--gold);
}

.entry-icon.tone-rose {
  background: color-mix(in srgb, var(--rose) 16%, transparent);
  color: var(--rose);
}

.entry-icon.tone-ink {
  background: var(--surface-3);
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ groups */

.month-group {
  margin-top: 22px;
}

.month-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 10px 4px;
  margin-bottom: 2px;
}

.month-head h3 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.month-head span {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.month-group .entries {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search svg {
  position: absolute;
  left: 14px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.search input::placeholder {
  color: var(--muted);
}

.search input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 14px;
  background: var(--surface-2);
}

.seg button {
  flex: 1;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s;
}

.seg button.on {
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(58, 38, 26, 0.08);
}

.seg.compact {
  width: 100%;
}

/* ------------------------------------------------------------------ panels */

.panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 0;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
}

.panel-head p {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.panel-body {
  padding: 16px 18px 18px;
}

.panel-foot {
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.rows {
  display: flex;
  flex-direction: column;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.setting-row:first-child {
  border-top: 0;
}

.setting-copy {
  min-width: 0;
}

.setting-copy strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.setting-copy span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.setting-row button {
  flex: 0 0 auto;
}

.setting-row .chev {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ fields */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field + .field {
  margin-top: 14px;
}

.field > label,
.field-label {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
  -webkit-appearance: none;
  appearance: none;
}

select.input {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.input:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: var(--surface);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 11%, transparent);
}

.input::placeholder {
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row .field + .field {
  margin-top: 0;
}

/* ----------------------------------------------------------------- dialogs */

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(28, 18, 12, 0.44);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sheet {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  overflow: hidden;
}

.sheet-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding: 12px 12px 0;
  padding-top: calc(52px + env(safe-area-inset-top));
}

.sheet-card {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: 100%;
  padding: 10px 20px calc(18px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: rise 0.32s var(--ease);
}

.sheet-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 4px;
}

.sheet-grip {
  width: 38px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--line-2);
  flex: 0 0 auto;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.sheet-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.sheet-head .icon-btn {
  width: 34px;
  height: 34px;
}

.sheet-actions {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  flex: 0 0 auto;
}

.sheet-actions .btn-primary {
  flex: 1;
}

.modal {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  overflow: auto;
}

.modal-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: calc(24px + env(safe-area-inset-top)) 18px
    calc(24px + env(safe-area-inset-bottom));
}

.modal-card {
  width: min(430px, 100%);
  padding: 26px 24px;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop 0.26s var(--ease);
}

.modal-card h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.1;
}

.modal-card .lede {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-card form {
  margin-top: 20px;
}

.modal-actions {
  margin-top: 20px;
}

/* ------------------------------------------------------------ amount input */

.amount-field {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 2px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.cur-pick {
  flex: 0 0 auto;
  padding: 9px 27px 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: var(--surface-2);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.cur-pick:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 11%, transparent);
}

.amount-field .sym {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--muted);
}

.amount-field input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(38px, 11vw, 50px);
  letter-spacing: -0.03em;
  text-align: left;
  outline: none;
  font-variant-numeric: tabular-nums;
}

.amount-field input::placeholder {
  color: color-mix(in srgb, var(--muted) 55%, transparent);
}

.desc-input {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  padding: 4px 2px 12px;
  font-size: 17px;
  font-weight: 500;
}

.desc-input:focus {
  border-color: var(--accent);
  box-shadow: none;
  background: none;
}

/* ------------------------------------------------------------------- chips */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  margin: 0 -2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 8px 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, color 0.16s;
}

.chip svg {
  width: 15px;
  height: 15px;
}

.chip:hover {
  border-color: var(--line-2);
}

.chip.on {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 650;
}

/* ------------------------------------------------------------------ splits */

.split-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.split-box .split-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.share-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.share-field span {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.share-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  font-variant-numeric: tabular-nums;
}

.share-field input:focus {
  border-color: var(--accent);
}

.split-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 8px;
}

.split-hint.error {
  color: var(--danger);
}

/* --------------------------------------------------------------- country */

.country-select {
  font-weight: 550;
  letter-spacing: 0.01em;
}

/* ------------------------------------------------------------------- misc */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.pill .dot {
  width: 6px;
  height: 6px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.ok {
  background: var(--sage);
}

.dot.busy {
  background: var(--gold);
  animation: pulse 1.1s ease-in-out infinite;
}

.dot.off {
  background: var(--muted);
}

.dot.err {
  background: var(--danger);
}

.inline-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 24px;
  text-align: center;
}

.empty-art {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 22px;
  background: var(--surface-2);
  color: var(--muted);
}

.empty-art svg {
  width: 28px;
  height: 28px;
}

.empty h3 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
}

.empty p {
  max-width: 32ch;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.who-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.who-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, transform 0.16s var(--ease);
}

.who-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.who-card:active {
  transform: scale(0.97);
}

.avatar.big {
  width: 52px;
  height: 52px;
  font-size: 17px;
}

.avatar.alt {
  background: var(--accent);
}

body:has(dialog[open]) {
  overflow: hidden;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 62vh;
  color: var(--muted);
  font-size: 13.5px;
}

.loading .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  animation: breathe 1.8s ease-in-out infinite;
}

/* -------------------------------------------------------------------- dock */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  width: min(420px, calc(100% - 28px));
  padding: 7px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 24px 44px -26px rgba(40, 24, 14, 0.55);
}

.dock a,
.dock button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 2px;
  border: 0;
  border-radius: 18px;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.16s;
}

.dock a svg,
.dock button svg {
  width: 21px;
  height: 21px;
}

.dock a.active {
  color: var(--accent);
}

.dock a:hover,
.dock button:hover {
  color: var(--ink);
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(400px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 15px;
  background: var(--card);
  color: var(--on-card);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 0.24s var(--ease);
}

.toast svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--sage);
}

.toast button {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.toast.leaving {
  animation: toast-out 0.2s ease forwards;
}

/* ----------------------------------------------------------------- keyframe */

@keyframes rise {
  from {
    opacity: 0.6;
    transform: translateY(28px);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

@keyframes breathe {
  50% {
    transform: scale(0.92);
    opacity: 0.75;
  }
}

/* ---------------------------------------------------------------- converter */

.converter-panel {
  margin-top: 14px;
}

.converter-amounts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.converter-side {
  min-width: 0;
  padding: 5px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-2) 45%, transparent);
}

.converter-pick {
  width: 100%;
  padding: 6px 20px 6px 7px;
  border: 0;
  border-radius: 9px;
  background-color: transparent;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.converter-pick:hover {
  background-color: var(--surface-2);
}

.converter-box {
  position: relative;
  display: flex;
  align-items: center;
}

.converter-input {
  width: 100%;
  padding: 7px 30px 7px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: background 0.16s, box-shadow 0.16s;
}

.converter-input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 11%, transparent);
}

.converter-input::placeholder {
  color: var(--muted);
}

.converter-erase {
  position: absolute;
  right: 2px;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.converter-erase:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.converter-erase:active {
  transform: translateY(-50%) scale(0.92);
}

.converter-erase svg {
  width: 15px;
  height: 15px;
}

.converter-swap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.16s, color 0.16s, transform 0.13s;
}

.converter-swap:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.converter-swap:active {
  transform: scale(0.92);
}

.converter-swap svg {
  width: 16px;
  height: 16px;
  transform: rotate(90deg);
}

@media (min-width: 520px) {
  .converter-amounts {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    gap: 6px;
  }

  .converter-swap {
    margin-top: 8px;
  }

  .converter-swap svg {
    transform: none;
  }
}

.converter-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
  padding: 0 1px 1px;
}

.converter-chip {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s, transform 0.13s var(--ease);
}

.converter-chip:hover {
  background: var(--surface-2);
  border-color: var(--line-2);
}

.converter-chip:active {
  transform: scale(0.96);
}

.converter-rate {
  margin-top: 10px;
  font-size: 11.5px;
  text-align: center;
  color: var(--muted);
}

.converter-sync {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 0 2px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- responsive */

@media (min-width: 640px) {
  .app {
    padding-left: 26px;
    padding-right: 26px;
  }

  .topbar {
    margin-left: -26px;
    margin-right: -26px;
    padding-left: 26px;
    padding-right: 26px;
  }

  .balance-card {
    padding: 28px 28px 26px;
  }

  .sheet-wrap {
    align-items: center;
    padding: 24px;
  }

  .sheet-card {
    padding: 12px 26px 22px;
    border-radius: 26px;
  }

  .view-title {
    font-size: 38px;
  }
}

@media (min-width: 760px) {
  .topbar {
    position: static;
    margin: 0;
    padding: 20px 0 8px;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (max-width: 380px) {
  .entry-sub {
    display: none;
  }

  .legend-amount {
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
