/* 빙각의 일산 — 차분한 애플 스타일. 포인트 색은 --accent 하나만 */
:root {
  --bg: #f5f5f7;
  --card: #fff;
  --label: #1d1d1f;
  --label2: #6e6e73;
  --label3: #a1a1a6;
  --sep: rgba(0, 0, 0, .08);
  --fill: rgba(0, 0, 0, .04);
  --fill2: rgba(0, 0, 0, .07);
  --seg-on: #fff;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, .09);
  --on-accent: #fff;
  --danger: #d1453b;
  --nav: rgba(245, 245, 247, .82);
  --shadow: 0 1px 2px rgba(0, 0, 0, .03);
  --backdrop: rgba(0, 0, 0, .28);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Apple SD Gothic Neo",
    "Pretendard Variable", Pretendard, system-ui, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161617;
    --card: #222224;
    --label: #e8e8ed;
    --label2: #98989d;
    --label3: #5f5f64;
    --sep: rgba(255, 255, 255, .07);
    --fill: rgba(255, 255, 255, .05);
    --fill2: rgba(255, 255, 255, .09);
    --seg-on: #3a3a3d;
    --accent: #5ea3f5;
    --accent-soft: rgba(94, 163, 245, .14);
    --on-accent: #0f1a26;
    --danger: #e0726b;
    --nav: rgba(22, 22, 23, .8);
    --shadow: none;
    --backdrop: rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.4 var(--font);
  letter-spacing: -0.012em;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
a { color: inherit; text-decoration: none; }
input::placeholder { color: var(--label3); }
.muted { color: var(--label2); font-weight: 400; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 내비게이션 바 */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: var(--nav);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  backdrop-filter: saturate(160%) blur(20px);
  border-bottom: .5px solid transparent;
  transition: border-color .25s;
}
.nav.compact { border-bottom-color: var(--sep); }
.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  height: 48px;
  display: grid;
  grid-template-columns: 1fr minmax(0, auto) 1fr;
  align-items: center;
  padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
}
.nav-title {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56vw;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .25s, transform .25s;
}
.nav.compact .nav-title { opacity: 1; transform: none; }
.nav-back { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); padding: 10px 8px; font-size: 16px; }
.nav-back svg { width: 10px; height: 17px; }
.nav-right { justify-self: end; }
.nav-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent); }
.nav-btn svg { width: 22px; height: 22px; }

/* ---------- 레이아웃 */
.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.wrap.wide { max-width: 1080px; }
.large-title {
  margin: 8px 0 0;
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.02em;
  word-break: keep-all;
}
.title-btn { font: inherit; letter-spacing: inherit; text-align: left; }
.subtitle { margin: 6px 0 28px; color: var(--label2); font-size: 15px; }

.block-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 44px 4px 12px; }
.block-h h2 { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 600; letter-spacing: -.015em; }
.block-h span { color: var(--label2); font-size: 15px; font-variant-numeric: tabular-nums; }
.group-label { margin: 28px 4px 10px; font-size: 13px; color: var(--label2); }
.foot { margin: 12px 4px 0; font-size: 13px; color: var(--label2); line-height: 1.5; }
.warn { margin: 12px 0 0; padding: 14px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; color: var(--label2); background: var(--fill2); }

/* ---------- 인셋 그룹 리스트 */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row {
  --inset: 20px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  background: var(--card);
  text-align: left;
}
.row.av-row { --inset: 70px; }
.row:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: var(--inset);
  height: .5px;
  background: var(--sep);
}
button.row, a.row { transition: background .2s; }
button.row:active, a.row:active { background: var(--fill2); transition: none; }
@media (hover: hover) {
  button.row:hover, a.row:hover { background: color-mix(in srgb, var(--card) 97%, var(--label)); }
}
.row-main { flex: 1; min-width: 0; }
.row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { margin-top: 3px; font-size: 14px; color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.wrap-ok { white-space: normal; line-height: 1.45; }
.row-value { flex: none; color: var(--label2); font-variant-numeric: tabular-nums; }
.row-value.strong { color: var(--label); font-weight: 500; }
.chev { flex: none; width: 7px; height: 12px; color: var(--label3); }
.row.empty { color: var(--label2); justify-content: center; text-align: center; min-height: 96px; font-size: 15px; }
.row-add { color: var(--accent); gap: 12px; }
.row-add .plus-c { width: 20px; height: 20px; color: var(--accent); flex: none; }
.rc { flex: none; color: var(--label3); display: grid; }
.rc svg { width: 14px; height: 16px; }

.field { display: flex; align-items: center; gap: 8px; padding: 0 20px; min-height: 52px; }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 14px 0; }

/* ---------- 아바타 (무채색) */
.av {
  --s: 36px;
  width: var(--s);
  height: var(--s);
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--fill2);
  color: var(--label2);
  font-size: calc(var(--s) * .34);
  font-weight: 500;
  letter-spacing: -.04em;
  line-height: 1;
}
.faces { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.faces .av { --s: 28px; }

/* ---------- 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 500;
  transition: opacity .2s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { opacity: .6; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn.fill { background: var(--accent); color: var(--on-accent); }
.btn.tint { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.btn.plain { background: var(--card); box-shadow: var(--shadow); }
.btn.block { display: flex; width: 100%; }
.btn.danger, .danger { color: var(--danger); }
.link { color: var(--accent); font-size: 17px; padding: 10px 8px; }
.link.strong { font-weight: 600; }
.pill { padding: 7px 15px; border-radius: 999px; background: var(--fill2); color: var(--label); font-size: 14px; }
.pill:active { opacity: .6; }

/* ---------- 홈 */
.hero { display: flex; align-items: center; gap: 18px; margin: 16px 0 32px; }
.hero .large-title { margin: 0; }
.hero .subtitle { margin: 4px 0 0; }
.hero-logo { width: 84px; height: 84px; flex: none; border-radius: 50%; box-shadow: 0 4px 16px rgba(0, 0, 0, .08); }
@media (prefers-color-scheme: dark) { .hero-logo { box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); filter: brightness(.92); } }
@media (min-width: 720px) { .hero-logo { width: 104px; height: 104px; } .hero { gap: 24px; } }
.new-meeting { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 20px; }
.new-meeting input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 10px 0; }
.new-meeting .btn { min-height: 42px; padding: 0 18px; border-radius: 10px; font-size: 15px; }
.hero-note { margin: 12px 4px 0; font-size: 13px; line-height: 1.5; color: var(--label2); }

/* ---------- 모임 상세 */
.stats { display: grid; grid-template-columns: 1.6fr 1fr 1fr; background: var(--card); border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow); }
.stats div { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stats div + div { border-left: .5px solid var(--sep); }
.stats span { font-size: 13px; color: var(--label2); }
.stats b { font-size: clamp(17px, 4.6vw, 21px); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--fill2); }
.seg button { flex: 1; height: 34px; border-radius: 8px; font-size: 14px; color: var(--label2); text-align: center; transition: background .25s, color .25s; }
.seg button.on { background: var(--seg-on); color: var(--label); font-weight: 500; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.badge { margin-left: 5px; color: var(--label3); font-variant-numeric: tabular-nums; }

@media (max-width: 959px) {
  .cols[data-tab="rounds"] .col-settle, .cols[data-tab="settle"] .col-rounds { display: none; }
}
@media (min-width: 960px) {
  .seg { display: none; }
  .cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: start; }
  .col-settle { position: sticky; top: 56px; max-height: calc(100vh - 64px); overflow-y: auto; padding-bottom: 32px; scrollbar-width: thin; }
  .large-title { font-size: 40px; }
}
.add-round { margin-top: 32px; }

/* 송금 */
.tx { gap: 10px; }
.tx-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.tx-who .av { --s: 30px; }
.tx-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-arrow { flex: none; width: 14px; height: 14px; color: var(--label3); }
.tx-amt { flex: none; font-weight: 500; font-variant-numeric: tabular-nums; padding: 6px 6px; border-radius: 8px; }
.tx-amt:active { background: var(--fill2); }
.tx-check { flex: none; width: 24px; height: 24px; margin-left: 2px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--label3); color: transparent; transition: all .25s; }
.tx-check svg { width: 12px; height: 12px; }
.tx.done .tx-check { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tx.done .tx-who, .tx.done .tx-amt { opacity: .4; }
.tx.done .tx-amt { text-decoration: line-through; }
@media (max-width: 380px) { .tx-who .av { display: none; } }

.net { font-weight: 500; color: var(--label2); }
.net.pos { color: var(--accent); }
.net.neg { color: var(--label); }
.share { margin-top: 24px; }

/* ---------- 칩(멤버 선택) */
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--sep);
  font-size: 15px;
  transition: background .2s, color .2s, box-shadow .2s;
}
.chip span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .av { --s: 28px; }
.chip.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 500; }
.chip.on .av { background: var(--accent); color: var(--on-accent); }
.chip:active { transform: scale(.97); }
.quick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.quick .count { margin-left: auto; color: var(--label2); font-size: 14px; }
.toggle-all { margin-top: 12px; }

/* ---------- 시트 / 알림 */
dialog { padding: 0; border: 0; color: var(--label); }
dialog::backdrop { background: var(--backdrop); }
dialog.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  max-height: 92dvh;
  margin: auto auto 0;
  border-radius: 18px 18px 0 0;
  background: var(--bg);
  overflow: hidden;
  flex-direction: column;
  animation: sheet-up .36s cubic-bezier(.2, .9, .3, 1);
}
dialog.sheet[open] { display: flex; }
@keyframes sheet-up { from { transform: translateY(40%); opacity: 0; } }
@media (min-width: 720px) {
  dialog.sheet { margin: auto; border-radius: 18px; max-height: 86vh; box-shadow: 0 24px 64px rgba(0, 0, 0, .18); animation: sheet-pop .25s ease-out; }
}
@keyframes sheet-pop { from { transform: scale(.97); opacity: 0; } }
.sheet-head {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 58px;
  padding: 0 10px;
  border-bottom: .5px solid var(--sep);
  background: var(--card);
}
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 20px 20px calc(32px + env(safe-area-inset-bottom)); }
.sheet-scroll > .btn.block { margin-top: 36px; }

.amount-box { text-align: center; padding: 16px 0 4px; }
.amount-line { display: inline-flex; align-items: baseline; justify-content: center; gap: 4px; max-width: 100%; }
.amount-input {
  width: 1.2em;
  min-width: 1.2em;
  max-width: 80vw;
  border: 0;
  outline: 0;
  background: transparent;
  text-align: right;
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  padding: 0;
}
.amount-line span { font-size: 26px; font-weight: 500; color: var(--label2); }
.per { min-height: 20px; margin-top: 6px; font-size: 14px; color: var(--label2); }
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: none; background: var(--fill); cursor: zoom-in; }
.file-btn { cursor: pointer; }

dialog.alert {
  width: 280px;
  margin: auto;
  border-radius: 16px;
  overflow: hidden;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  animation: alert-pop .2s ease-out;
}
@keyframes alert-pop { from { transform: scale(1.06); opacity: 0; } }
.alert-body { padding: 22px 18px 18px; text-align: center; }
.alert-title { font-weight: 600; }
.alert-msg { margin-top: 6px; font-size: 14px; color: var(--label2); line-height: 1.45; }
.alert-input { width: 100%; margin-top: 16px; padding: 9px 12px; border: .5px solid var(--sep); border-radius: 9px; outline: 0; background: var(--bg); font-size: 15px; }
.alert-btns { display: flex; flex-direction: row-reverse; border-top: .5px solid var(--sep); }
.alert-btns button { flex: 1; height: 48px; text-align: center; color: var(--accent); font-size: 17px; }
.alert-btns button + button { border-right: .5px solid var(--sep); }
.alert-btns .strong { font-weight: 600; }
.alert-btns .danger { color: var(--danger); font-weight: 600; }
.alert-btns button:active { background: var(--fill); }

dialog.action { width: 100%; max-width: 420px; margin: auto auto max(12px, env(safe-area-inset-bottom)); background: transparent; padding: 0 12px; animation: sheet-up .3s cubic-bezier(.2, .9, .3, 1); }
@media (min-width: 720px) { dialog.action { margin: auto; } }
.action-group { border-radius: 16px; overflow: hidden; background: color-mix(in srgb, var(--card) 96%, transparent); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); }
.action-group + .action-group { margin-top: 8px; }
.action-group button { display: block; width: 100%; height: 56px; text-align: center; font-size: 18px; color: var(--accent); }
.action-group button + button { border-top: .5px solid var(--sep); }
.action-group button:active { background: var(--fill); }
.action-group .cancel { font-weight: 600; }

dialog.viewer { max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; margin: 0; background: rgba(0, 0, 0, .9); display: none; }
dialog.viewer[open] { display: grid; place-items: center; }
dialog.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
dialog.viewer button { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 16px; width: 36px; height: 36px; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 17px; text-align: center; }

/* ---------- 토스트 / 로딩 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: calc(100vw - 40px);
  padding: 12px 20px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--label) 82%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: var(--bg);
  font-size: 15px;
  transform: translate(-50%, 16px);
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { padding: 96px 0; text-align: center; color: var(--label2); }
.spinner { width: 22px; height: 22px; margin: 0 auto 14px; border-radius: 50%; border: 2px solid var(--fill2); border-top-color: var(--label2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
