:root{
  --bg:#f6f5f1; --card:#ffffff; --ink:#1d2124; --sub:#6b7176; --line:#e4e2dc;
  --accent:#0f766e; --accent-ink:#ffffff; --accent-soft:#e3f1ef;
  --plus:#b45309; --minus:#2563eb; --danger:#c2410c;
  --shadow:0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme:light;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#16181a; --card:#1f2225; --ink:#e9eaeb; --sub:#9aa0a5; --line:#33373b;
    --accent:#2bb3a3; --accent-ink:#0b1514; --accent-soft:#1d3532;
    --plus:#f0a35a; --minus:#7aa7ff; --danger:#f08a5d;
    --shadow:none;
    color-scheme:dark;
  }
}
*{ box-sizing:border-box; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size:16px; line-height:1.55;
  padding-bottom:env(safe-area-inset-bottom);
}
button, input{ font:inherit; color:inherit; }
button{ cursor:pointer; }
a{ color:var(--accent); }
.num{ font-variant-numeric:tabular-nums; }

.bar{ max-width:640px; margin:0 auto; padding:14px 16px 4px; }
.brand{ color:var(--ink); text-decoration:none; font-weight:700; letter-spacing:.04em; font-size:15px; }
.brand::before{ content:""; display:inline-block; width:18px; height:18px; margin-right:8px; vertical-align:-3px;
  background:url(/icon.svg) center/contain no-repeat; }
main{ max-width:640px; margin:0 auto; padding:8px 16px 96px; }

h1{ font-size:24px; margin:12px 0 4px; line-height:1.3; word-break:break-word; }
h2{ font-size:14px; color:var(--sub); font-weight:600; margin:28px 0 10px; letter-spacing:.04em; }
.lead{ color:var(--sub); margin:0 0 16px; font-size:14px; }
.card{ background:var(--card); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); }
.pad{ padding:16px; }

/* ---------- 入力 ---------- */
label.f{ display:block; font-size:13px; color:var(--sub); margin:14px 0 6px; font-weight:600; }
input.t{
  width:100%; padding:11px 12px; border:1px solid var(--line); border-radius:10px;
  background:var(--bg); outline:none; min-height:44px;
}
input.t:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
input.big{ font-size:22px; font-weight:700; }
.row{ display:flex; gap:8px; align-items:center; }
.row > .grow{ flex:1; min-width:0; }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  min-height:44px; padding:0 16px; border-radius:10px; border:1px solid var(--line);
  background:var(--card); font-weight:600; font-size:15px; text-decoration:none; color:var(--ink);
}
.btn.primary{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
.btn.ghost{ background:transparent; border-color:transparent; color:var(--accent); padding:0 8px; }
.btn.danger{ color:var(--danger); }
.btn.wide{ width:100%; }
.btn.small{ min-height:34px; padding:0 12px; font-size:13px; }
.btn:disabled{ opacity:.45; cursor:default; }
.icon-btn{ width:44px; padding:0; color:var(--sub); }

.chips{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{
  min-height:40px; padding:0 14px; border-radius:999px; border:1px solid var(--line);
  background:var(--card); font-size:15px;
}
.chip[aria-pressed="true"]{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink); font-weight:600; }

.seg{ display:flex; background:var(--bg); border:1px solid var(--line); border-radius:10px; padding:3px; }
.seg button{ flex:1; min-height:38px; border:0; background:transparent; border-radius:8px; font-weight:600; color:var(--sub); }
.seg button[aria-pressed="true"]{ background:var(--card); color:var(--ink); box-shadow:var(--shadow); }
@media (prefers-color-scheme: dark){ .seg button[aria-pressed="true"]{ background:var(--line); } }

/* ---------- トップ ---------- */
.hero{ margin:18px 0 22px; }
.hero h1{ font-size:28px; }
.example{ font-size:13px; color:var(--sub); margin-top:10px; padding:10px 12px; border-radius:10px; background:var(--accent-soft); color:var(--ink); }
.member-in{ margin-bottom:8px; }
.recent a{ display:flex; justify-content:space-between; padding:14px 16px; text-decoration:none; color:var(--ink); border-top:1px solid var(--line); }
.recent a:first-child{ border-top:0; }
.recent .sub{ color:var(--sub); font-size:13px; }

/* ---------- グループ ---------- */
.ghead{ display:flex; align-items:flex-start; gap:8px; }
.ghead h1{ flex:1; }
.members-line{ color:var(--sub); font-size:14px; margin:0 0 14px; }
.actions{ display:flex; gap:8px; flex-wrap:wrap; }

.total{ display:flex; justify-content:space-between; align-items:baseline; padding:14px 16px; border-bottom:1px solid var(--line); }
.total b{ font-size:22px; }
.xfer{ display:flex; align-items:center; gap:10px; padding:14px 16px; border-top:1px solid var(--line); }
.xfer:first-child{ border-top:0; }
.xfer .who{ flex:1; min-width:0; }
.xfer .who .arrow{ color:var(--sub); margin:0 6px; }
.xfer .amt{ font-weight:700; font-size:18px; }
.done{ padding:22px 16px; text-align:center; color:var(--sub); }

.pay{ display:block; width:100%; text-align:left; border:0; background:none; padding:14px 16px; border-top:1px solid var(--line); }
.pay:first-child{ border-top:0; }
.pay .top{ display:flex; gap:10px; align-items:baseline; }
.pay .title{ flex:1; min-width:0; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pay .amt{ font-weight:700; }
.pay .meta{ color:var(--sub); font-size:13px; margin-top:2px; }
.badge{ display:inline-block; font-size:11px; font-weight:700; padding:1px 7px; border-radius:6px; background:var(--accent-soft); color:var(--accent); margin-left:6px; vertical-align:1px; }
.split{ display:flex; flex-wrap:wrap; gap:4px 12px; font-size:13px; margin-top:4px; color:var(--sub); }
.split b{ color:var(--ink); font-weight:600; }

table.sum{ width:100%; border-collapse:collapse; font-size:14px; }
table.sum th, table.sum td{ padding:10px 12px; text-align:right; border-top:1px solid var(--line); white-space:nowrap; }
table.sum th:first-child, table.sum td:first-child{ text-align:left; white-space:normal; }
table.sum thead th{ border-top:0; color:var(--sub); font-weight:600; font-size:12px; }
.plus{ color:var(--plus); } .minus{ color:var(--minus); }
.empty{ padding:28px 16px; text-align:center; color:var(--sub); font-size:14px; }

.fab{
  position:fixed; left:50%; transform:translateX(-50%); bottom:calc(18px + env(safe-area-inset-bottom));
  min-height:52px; padding:0 26px; border-radius:999px; border:0;
  background:var(--accent); color:var(--accent-ink); font-weight:700; font-size:16px;
  box-shadow:0 6px 20px rgba(0,0,0,.18); z-index:5;
}

/* ---------- シート（入力画面） ---------- */
.sheet{ position:fixed; inset:0; z-index:20; display:flex; align-items:flex-end; justify-content:center; }
.sheet[hidden]{ display:none; }
.sheet-back{ position:absolute; inset:0; background:rgba(0,0,0,.4); }
.sheet-card{
  position:relative; width:100%; max-width:560px; max-height:92vh; max-height:92dvh; overflow:auto;
  background:var(--card); border-radius:18px 18px 0 0; padding:6px 16px calc(16px + env(safe-area-inset-bottom));
  overscroll-behavior:contain;
}
@media (min-width:600px){
  .sheet{ align-items:center; }
  .sheet-card{ border-radius:18px; }
}
.sheet-head{ display:flex; align-items:center; position:sticky; top:-6px; background:var(--card); padding:8px 0; z-index:1; }
.sheet-head h3{ flex:1; margin:0; font-size:17px; text-align:center; }
.sheet-head .btn{ min-width:72px; }
.sheet-foot{ display:flex; gap:8px; margin-top:20px; }
.sheet-foot .primary{ flex:1; }
.err{ color:var(--danger); font-size:14px; margin-top:12px; min-height:1em; }

/* 傾斜の行 */
.tilt-help{ font-size:13px; color:var(--sub); margin:8px 0 4px; }
.trow{ display:grid; grid-template-columns:minmax(0,1fr) auto auto; gap:8px; align-items:center; padding:10px 0; border-top:1px solid var(--line); }
.trow:first-of-type{ border-top:0; }
.trow .name{ line-height:1.35; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.trow .share{ display:block; font-size:13px; overflow:hidden; text-overflow:ellipsis; color:var(--sub); }
.trow .share b{ color:var(--ink); }
.adj{ display:flex; align-items:center; border:1px solid var(--line); border-radius:10px; background:var(--bg); height:44px; }
.adj button{ border:0; background:none; width:36px; height:100%; font-size:18px; font-weight:700; }
.adj .sign.p{ color:var(--plus); } .adj .sign.m{ color:var(--minus); } .adj .sign.z{ color:var(--sub); }
.adj input{ width:76px; border:0; background:none; outline:none; text-align:right; padding:0 4px 0 0; font-weight:600; height:100%; }
.adj .yen{ color:var(--sub); font-size:13px; padding-right:8px; }
.step{ display:flex; gap:4px; }
.step button{ min-height:44px; width:44px; border:1px solid var(--line); border-radius:10px; background:var(--card); font-size:12px; font-weight:600; color:var(--sub); padding:0; }
@media (max-width:380px){
  .adj input{ width:60px; }
  .adj button{ width:30px; }
  .step button{ width:40px; }
}
.check{ font-size:13px; margin-top:8px; padding:8px 10px; border-radius:8px; background:var(--bg); color:var(--sub); }
.check.bad{ color:var(--danger); }

.toast{
  position:fixed; left:50%; bottom:calc(84px + env(safe-area-inset-bottom)); transform:translateX(-50%);
  background:var(--ink); color:var(--bg); padding:10px 16px; border-radius:10px; font-size:14px; z-index:30;
  max-width:calc(100% - 32px);
}
.share-url{ font-size:13px; word-break:break-all; color:var(--sub); padding:10px 12px; background:var(--bg); border-radius:10px; margin:8px 0; }
.sub{ color:var(--sub); }
