/* how2split — styles */
:root {
  /* Light: white + orange (from ningnawang.github.io) */
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f5f3;
  --ink: #1c1c1d;
  --muted: #6b6b70;
  --line: #ebe9e6;
  --accent: #dd7e01;          /* fills: primary buttons, toggle, logo */
  --accent-hover: #c87100;
  --accent-ink: #1c1c1d;      /* text on an accent fill */
  --btn-bg: #ef9a33;          /* primary buttons: a bit lighter than the brand orange */
  --btn-hover: #e88d1f;
  --btn-ink: #1c1c1d;
  --accent-text: #b45309;     /* accent-colored text and links on surfaces */
  --accent-soft: #fdf1e3;     /* tinted backgrounds: badges, avatars */
  --accent-soft-ink: #a35200;
  --logo-a: #dd7e01;
  --logo-b: #ffc98a;
  --heart: #e0567a;
  --pos: #1f7a45;
  --neg: #c0392b;
  --focus: rgba(221, 126, 1, .35);
  --shadow: 0 1px 2px rgba(28, 28, 29, .05), 0 6px 20px rgba(28, 28, 29, .06);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* Dark theme: used when the system is dark (unless the user picked light with the
   top-right button), or when the user picked dark. theme.js sets data-theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    /* Dark: near-black + purple */
    --bg: #1c1c1d;
    --surface: #212529;
    --surface-2: #2b3036;
    --ink: #f0f0f0;
    --muted: #a7a9ad;
    --line: #3a3f45;
    --accent: #b794f6;
    --accent-hover: #c7abf8;
    --accent-ink: #1c1c1d;
    --btn-bg: #b794f6;
    --btn-hover: #c7abf8;
    --btn-ink: #1c1c1d;
    --accent-text: #c4a5ff;
    --accent-soft: #2d2640;
    --accent-soft-ink: #d9c6ff;
    --logo-a: #b794f6;
    --logo-b: #f67695;
    --heart: #f67695;
    --pos: #6cc791;
    --neg: #ef8277;
    --focus: rgba(183, 148, 246, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  /* Dark: near-black + purple */
  --bg: #1c1c1d;
  --surface: #212529;
  --surface-2: #2b3036;
  --ink: #f0f0f0;
  --muted: #a7a9ad;
  --line: #3a3f45;
  --accent: #b794f6;
  --accent-hover: #c7abf8;
  --accent-ink: #1c1c1d;
  --btn-bg: #b794f6;
  --btn-hover: #c7abf8;
  --btn-ink: #1c1c1d;
  --accent-text: #c4a5ff;
  --accent-soft: #2d2640;
  --accent-soft-ink: #d9c6ff;
  --logo-a: #b794f6;
  --logo-b: #f67695;
  --heart: #f67695;
  --pos: #6cc791;
  --neg: #ef8277;
  --focus: rgba(183, 148, 246, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--accent-text); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 48px 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }
.mb { margin-bottom: 14px; }
.mt { margin-top: 8px; }
.ic { display: inline-flex; }
.ic svg { width: 16px; height: 16px; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1040px; width: 100%; margin: 0 auto; padding: 14px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; }
.logo { width: 26px; height: 26px; }
.logo-a { fill: var(--logo-a); }
.logo-b { fill: var(--logo-b); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.lang, .icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; min-height: 32px; font: 600 13px var(--font); cursor: pointer;
}
.lang { padding: 4px 12px; }
.icon-btn { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
.icon-btn svg { width: 16px; height: 16px; }
.lang:hover, .icon-btn:hover { border-color: var(--muted); }

/* cards & forms */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-height: 40px;
}
input:focus, select:focus, button:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row > .fixed { flex: none; }
.row > .grow2 { flex: 2; }
.field { display: block; margin-bottom: 12px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.field-head > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-head .linkbtn { padding: 0; }
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.expense .meta .day { color: var(--ink); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 14px var(--font); border-radius: 10px; padding: 9px 14px; min-height: 40px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--btn-ink); }
.btn.primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn.danger { color: var(--neg); }
.btn.armed { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }

.error { color: var(--neg); font-size: 13px; margin: -4px 0 10px; min-height: 0; }
.error:empty { display: none; }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 12px; }
.hint:empty { display: none; }

/* home */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: start; padding: 36px 0 24px; }
.hero h1 { font-size: 38px; letter-spacing: -.02em; margin-bottom: 14px; }
.hero .sub { color: var(--muted); font-size: 16px; max-width: 34em; }
.steps { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-soft-ink);
  font-weight: 700; font-size: 13px; display: grid; place-items: center;
}
.recent { margin-top: 28px; }
.recent ul { list-style: none; padding: 0; margin: 8px 0 0; }
.recent li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.recent li a { text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* bill page */
.bill-head { padding: 18px 0 16px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.bill-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.bill-title h1 { overflow-wrap: anywhere; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-soft-ink); letter-spacing: .02em;
}
.badge.grey { background: var(--surface-2); color: var(--muted); }
.share { display: flex; gap: 8px; align-items: center; flex: 0 1 430px; min-width: 0; }
.share input { font-size: 13px; color: var(--muted); background: var(--surface-2); }
.grid { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; padding-bottom: 32px; }
.col { min-width: 0; }

.whoami { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 700; font-size: 14px;
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--focus); }
.switch input:disabled + .track { opacity: .6; }

.transfer { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.transfer:first-child { border-top: 0; }
.transfer .names { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.transfer .arrow { color: var(--muted); }
.transfer .amt { font-weight: 700; }
.settled { display: flex; align-items: center; gap: 8px; color: var(--pos); font-weight: 600; padding: 6px 0; }
.settled svg { width: 18px; height: 18px; }

.member { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.member:first-child { border-top: 0; }
.member .info { flex: 1; min-width: 0; }
.member .nm { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.member .bal { text-align: right; }
.member .bal .lbl { display: block; font-size: 11px; color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.add-member { margin-top: 12px; }

.expense {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-top: 1px solid var(--line);
}
.expense:first-child { border-top: 0; }
.expense .info { flex: 1; min-width: 0; }
.expense .t { font-weight: 650; overflow-wrap: anywhere; }
.expense .meta { font-size: 13px; color: var(--muted); }
.expense .right { text-align: right; flex: none; }
.expense .amt { font-weight: 700; font-size: 16px; }
.expense .actions { display: flex; gap: 4px; justify-content: flex-end; margin-top: 4px; }
.expense.payment .t { color: var(--muted); }
.totals { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 4px; }

/* expense form */
.form-card { border-color: var(--accent); margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font);
  padding: 6px 14px; border-radius: 8px; cursor: pointer; min-height: 32px;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.plist { border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 14px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); }
.prow:first-child { border-top: 0; }
.prow label { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.prow label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow input.sh { width: 72px; min-height: 32px; padding: 4px 8px; text-align: right; }
.prow .part { width: 92px; text-align: right; color: var(--muted); font-size: 13px; }
.prow.off .part { opacity: .4; }
.plist-head { display: flex; align-items: center; justify-content: space-between; }
.linkbtn { border: 0; background: none; color: var(--accent-text); font: 600 13px var(--font); cursor: pointer; padding: 2px 4px; }
.money { position: relative; }
.money .cur { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 14px; }
.money input { padding-left: calc(14px + var(--cur-w, 1ch)); }
.form-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.form-actions .r { display: flex; gap: 8px; }

.edit-bill { display: grid; grid-template-columns: 1fr 120px auto auto; gap: 8px; align-items: center; width: 100%; }

.foot { padding: 20px 16px 32px; font-size: 13px; color: var(--muted); text-align: center; }
.foot p + p { margin-top: 2px; }
.foot .donate { margin-top: 12px; }
.foot .donate a {
  display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-weight: 600;
  text-decoration: none; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.foot .donate a:hover { border-color: var(--accent); }
.foot .donate .ic svg { width: 14px; height: 14px; color: var(--heart); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  transition: all .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 16px; }
  .hero h1 { font-size: 30px; }
}
@media (max-width: 520px) {
  h1 { font-size: 22px; }
  .share { flex-basis: 100%; }
  .card { padding: 15px; }
  .edit-bill { grid-template-columns: 1fr 96px; }
  .row.stack-sm { flex-direction: column; gap: 0; }
  .edit-bill .btn { width: 100%; }
  .prow .part { width: 76px; }
  .prow input.sh { width: 60px; }
}
