/* SplitJapan — dark-first, typography-driven, izakaya-proof */

:root {
  --bg: #101014;
  --card: #1a1a21;
  --card-2: #22222b;
  --line: #2e2e3a;
  --text: #f2f0eb;
  --muted: #9b98a3;
  --accent: #e8503a;        /* vermilion — torii red, not emoji red */
  --accent-soft: #3a1e1a;
  --pos: #5dbb8a;
  --neg: #e8836f;
  --radius: 14px;
  font-size: 16px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f4ef;
    --card: #ffffff;
    --card-2: #f0ede6;
    --line: #e2ded4;
    --text: #1c1b20;
    --muted: #6d6a75;
    --accent: #d43f2a;
    --accent-soft: #fbe6e1;
    --pos: #217a52;
    --neg: #c05138;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); }
body {
  font-family: "Avenir Next", "Helvetica Neue", -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

#app { max-width: 480px; margin: 0 auto; padding: 20px 16px 48px; }

.hidden { display: none !important; }

/* ---- brand / setup ---- */
.brand { text-align: center; padding: 40px 0 24px; }
.brand h1 {
  font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em;
}
.brand h1::after { content: "."; color: var(--accent); }
.tagline { color: var(--muted); margin-top: 8px; font-size: 0.95rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card.slim { padding: 12px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.field-label {
  display: block; font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 16px 0 8px;
}
.field-label.inline { margin: 0; }
.field-label:first-child { margin-top: 0; }

input[type="text"], textarea {
  width: 100%; background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 1rem; font-family: inherit;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.member-row { display: flex; gap: 8px; margin-bottom: 8px; }
.member-row input { flex: 1; }
.member-row select {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 10px; font-size: 0.95rem; font-family: inherit;
}
.member-row .remove {
  background: none; border: none; color: var(--muted); font-size: 1.2rem;
  cursor: pointer; padding: 0 6px;
}

/* ---- buttons ---- */
.primary-btn {
  display: block; width: 100%;
  background: var(--accent); color: #fff;
  border: none; border-radius: 12px;
  padding: 15px; font-size: 1.05rem; font-weight: 700; font-family: inherit;
  cursor: pointer; margin-top: 18px;
  transition: transform 0.06s;
}
.primary-btn:active { transform: scale(0.98); }
.primary-btn.big { padding: 18px; font-size: 1.15rem; margin: 4px 0 14px; }

.ghost-btn {
  background: none; border: 1px dashed var(--line); color: var(--muted);
  border-radius: 10px; padding: 10px 14px; font-size: 0.95rem; font-family: inherit;
  cursor: pointer; width: 100%;
}
.ghost-btn.danger { color: var(--neg); border-color: var(--neg); border-style: solid; opacity: 0.8; }

.share-btn {
  background: var(--card-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 18px; font-weight: 700; font-size: 0.95rem;
  font-family: inherit; cursor: pointer;
}

/* ---- main ---- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px 16px; gap: 12px; }
.topbar h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 0.85rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 8px 15px; font-size: 0.95rem; font-family: inherit;
  cursor: pointer; user-select: none;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.chip.dim { opacity: 0.45; }

.balance-hero { text-align: center; padding: 24px 18px; }
.balance-hero .who { color: var(--muted); font-size: 0.9rem; }
.balance-hero .amt { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0; }
.balance-hero .amt.pos { color: var(--pos); }
.balance-hero .amt.neg { color: var(--neg); }
.balance-hero .conv { color: var(--muted); font-size: 1rem; }

.section-title { font-size: 1rem; font-weight: 800; margin-bottom: 12px; letter-spacing: -0.01em; }
.count { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.settle-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line); gap: 8px;
}
.settle-line:last-child { border-bottom: none; }
.settle-line .flow { font-size: 0.98rem; }
.settle-line .flow strong { font-weight: 700; }
.settle-line .val { text-align: right; white-space: nowrap; }
.settle-line .val .jpy { font-weight: 800; }
.settle-line .val .home { display: block; color: var(--muted); font-size: 0.82rem; }
.all-settled { color: var(--pos); font-weight: 700; text-align: center; padding: 8px 0; }

.exp-item {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.exp-item:last-child { border-bottom: none; }
.exp-item .l .cat { font-weight: 700; font-size: 0.98rem; }
.exp-item .l .meta { color: var(--muted); font-size: 0.82rem; }
.exp-item .r { text-align: right; white-space: nowrap; }
.exp-item .r .jpy { font-weight: 800; }
.exp-item .r .orig { display: block; color: var(--muted); font-size: 0.8rem; }
.tf-tag { color: var(--accent); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; }

.foot { text-align: center; margin-top: 22px; }
.foot .ghost-btn { width: auto; margin: 0 auto 14px; }
.hint { color: var(--muted); font-size: 0.8rem; margin-top: 10px; }
.hint.center { text-align: center; }

/* ---- sheets ---- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.sheet {
  background: var(--card); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px; padding: 14px 20px 30px;
  max-height: 92vh; overflow-y: auto;
  border: 1px solid var(--line); border-bottom: none;
}
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }

.amount-wrap {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px 12px; margin-top: 4px;
}
.currency-btn {
  background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: 8px; padding: 10px 12px;
  font-weight: 800; font-size: 1rem; font-family: inherit; cursor: pointer;
  flex-shrink: 0;
}
#amount-input {
  border: none; background: none; font-size: 2rem; font-weight: 800;
  text-align: right; padding: 6px 4px; letter-spacing: -0.01em;
}
#amount-input:focus { outline: none; }

.taxfree-row {
  display: flex; align-items: center; gap: 10px; margin: 18px 0 4px;
  font-size: 0.95rem; cursor: pointer;
}
.taxfree-row small { color: var(--muted); display: block; font-size: 0.78rem; }
.taxfree-row input { width: 18px; height: 18px; accent-color: var(--accent); }

#note-input { margin-top: 14px; }

.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions .ghost-btn { width: auto; flex: 1; }
.sheet-actions .primary-btn { margin-top: 0; flex: 2; }

#share-url { font-size: 0.78rem; color: var(--muted); word-break: break-all; margin-top: 12px; resize: none; }

.foot-link { color: var(--accent); }

.how-it-works .hiw-list { padding-left: 20px; }
.how-it-works .hiw-list li { margin-bottom: 10px; font-size: 0.95rem; line-height: 1.5; }
.how-it-works .hint { margin-top: 14px; }

.share-btn.attention { background: var(--accent); border-color: var(--accent); color: #fff; }
.add-member-later { border-style: dashed; color: var(--muted); background: none; }
.settle-line[data-from] { cursor: pointer; }

.tagline-sub { color: var(--muted); font-size: 0.85rem; margin-top: 10px; }
.save-another { margin-top: 10px; border-style: dashed; }
.qr-box { display: flex; justify-content: center; margin: 14px 0 4px; }
.qr-box svg { width: 190px; height: 190px; background: #fff; border-radius: 10px; padding: 6px; }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  border-radius: 999px; padding: 10px 22px; font-weight: 700; font-size: 0.9rem;
  z-index: 99; white-space: nowrap;
}
