/* n차 정산 — 차수마다 한 장씩 뜯는 번호표. 그림자 대신 선, 장식 대신 차수 색. */
:root {
  color-scheme: light;
  --bg: #EFEEE9;
  --paper: #FBFAF7;
  --ink: #141414;
  --ink2: #4A4945;
  --ink3: #8A8883;
  --line: #D8D6CF;
  --line2: #C2BFB6;
  --accent: #FF4F1A;
  --ok: #0E8A5F;
  --warn: #B42318;
  --r1: #FF4F1A; --r2: #2563FF; --r3: #0E9F6E; --r4: #D99A00; --r5: #E0457B; --r6: #141414;
  --sans: 'IBM Plex Sans KR', -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
  --gut: 18px;
  --bar: 84px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
  word-break: keep-all; overflow-wrap: break-word; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.nw { white-space: nowrap; }
.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--bar) + env(safe-area-inset-bottom) + 24px); }
@media (min-width: 520px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

/* 머리줄 */
.head { position: sticky; top: 0; z-index: 20; background: rgba(239,238,233,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.head-in { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 var(--gut); }
.back { width: 36px; height: 36px; margin-left: -8px; border: 0; background: none; color: var(--ink); text-decoration: none; font-size: 22px; line-height: 1; display: grid; place-items: center; border-radius: 8px; }
.back:active { background: rgba(0,0,0,.06); }
.head-t { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { font-family: var(--mono); font-weight: 600; font-size: 17px; letter-spacing: -.03em; }
.logo i { font-style: normal; color: var(--accent); }

.sec { padding: 22px var(--gut) 0; }
.sec-t { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--ink3); letter-spacing: .02em; display: flex; justify-content: space-between; align-items: baseline; }
.lead { margin: 0; color: var(--ink2); font-size: 15.5px; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 54px; padding: 0 20px; border-radius: 12px; border: 1.5px solid var(--ink); background: var(--paper); font-weight: 700; font-size: 16.5px; text-decoration: none; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-ink { background: var(--ink); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { height: 40px; padding: 0 14px; font-size: 14.5px; border-radius: 10px; }
.btn:disabled { opacity: .35; }
.link { border: 0; background: none; padding: 6px 0; font-weight: 600; font-size: 14.5px; color: var(--ink2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line2); }

/* 아래 고정 줄 */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bg); border-top: 1px solid var(--line); padding: 12px var(--gut) calc(12px + env(safe-area-inset-bottom)); }
.bar-in { max-width: 444px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.bar-sum { flex: 1; min-width: 0; }
.bar-sum small { display: block; font-size: 12.5px; color: var(--ink3); font-weight: 600; }
.bar-sum b { font-size: 22px; }

/* 처음 화면 */
.hero { padding: 36px var(--gut) 8px; }
.hero-tag { display: inline-flex; gap: 6px; margin: 0 0 18px; }
.hero-tag span { font-family: var(--mono); font-weight: 600; font-size: 13px; padding: 3px 8px; border-radius: 6px; color: #fff; }
.hero h1 { margin: 0; font-size: 40px; line-height: 1.18; letter-spacing: -.04em; word-spacing: .08em; font-weight: 700; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { margin: 16px 0 0; color: var(--ink2); font-size: 16.5px; }
.hero-cta { display: grid; gap: 10px; margin-top: 28px; }
.how { margin: 30px var(--gut) 0; border-top: 1.5px solid var(--ink); }
.how li { list-style: none; display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.how b { font-family: var(--mono); font-size: 15px; }
.how p { margin: 0; font-size: 15px; color: var(--ink2); }
.how p strong { color: var(--ink); }
.how ol, ul.how { padding: 0; }
.rooms { display: grid; gap: 8px; }
.room-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.room-row div { flex: 1; min-width: 0; }
.room-row b { display: block; font-size: 16px; }
.room-row span { font-size: 13.5px; color: var(--ink3); }

/* 번호표(차수) */
.ticket { position: relative; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 14px; margin-bottom: 14px; }
.ticket::before, .ticket::after { content: ''; position: absolute; top: 62px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--ink); }
.ticket::before { left: -9px; clip-path: inset(0 0 0 50%); }
.ticket::after { right: -9px; clip-path: inset(0 50% 0 0); }
.t-head { height: 70px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1.5px dashed var(--line2); }
.t-no { flex: none; width: 46px; height: 46px; border-radius: 10px; color: #fff; display: grid; place-items: center; font-family: var(--mono); font-weight: 600; font-size: 15px; line-height: 1; }
.t-no small { display: block; font-size: 10px; opacity: .85; font-family: var(--sans); font-weight: 600; margin-top: 2px; }
.t-title { flex: 1; min-width: 0; }
.t-title b { display: block; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-title span { font-size: 13px; color: var(--ink3); }
.t-amt { font-size: 19px; font-weight: 600; text-align: right; }
.t-amt small { display: block; font-family: var(--sans); font-size: 11.5px; color: var(--ink3); font-weight: 500; letter-spacing: 0; }
.t-body { padding: 14px 16px 16px; }
.t-body.off { opacity: .45; }

/* 갔어요 / 안 갔어요 */
.go { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; }
.go button { height: 48px; border: 0; background: var(--paper); font-weight: 700; font-size: 15.5px; color: var(--ink3); }
.go button + button { border-left: 1.5px solid var(--ink); }
.go button.on { background: var(--ink); color: #fff; }
.items { margin-top: 12px; display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.item-t { flex: 1; font-size: 15px; }
.item-t span { display: block; font-size: 12.5px; color: var(--ink3); }
.sw { position: relative; flex: none; width: 92px; height: 34px; border-radius: 8px; border: 1.5px solid var(--ink); background: var(--ink); color: #fff; font-weight: 700; font-size: 13.5px; }
.sw.off { background: #fff; color: var(--ink3); border-color: var(--line2); text-decoration: line-through; }
.mine { margin-top: 12px; display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--ink2); }
.mine b { font-size: 17px; color: var(--ink); }
.paid-by { margin-top: 10px; font-size: 13.5px; color: var(--ink3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* 사람 */
.av { flex: none; width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; border: 1.5px solid var(--ink); background: var(--c, #fff); }
.av-sm { width: 22px; height: 22px; font-size: 10.5px; border-width: 1.2px; }
.avs { display: inline-flex; }
.avs .av { margin-left: -6px; } .avs .av:first-child { margin-left: 0; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px 0 7px; border: 1.5px solid var(--line2); border-radius: 22px; background: var(--paper); font-weight: 600; }
.pchip.on { border-color: var(--ink); background: var(--ink); color: #fff; }
.pchip.on .av { border-color: #fff; }
.pchip .tag { font-size: 11.5px; color: var(--ink3); font-weight: 600; }
.pchip.taken { opacity: .5; border-style: dashed; }

/* 입력 */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13.5px; font-weight: 700; color: var(--ink2); }
.input { height: 50px; padding: 0 14px; border: 1.5px solid var(--line2); border-radius: 10px; background: #fff; font-size: 16.5px; width: 100%; }
.input:focus { outline: none; border-color: var(--ink); }
.input.num { font-size: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.money { position: relative; }
.money .input { padding-right: 34px; text-align: right; }
.money::after { content: '원'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink3); font-size: 15px; }
select.input { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23141414' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center; padding-right: 36px; }
.seg { display: inline-grid; grid-auto-flow: column; border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; }
.seg button { height: 42px; padding: 0 14px; border: 0; background: var(--paper); font-weight: 600; font-size: 14.5px; color: var(--ink3); }
.seg button + button { border-left: 1.5px solid var(--ink); }
.seg button.on { background: var(--ink); color: #fff; }
.sub-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.sub-row .input { height: 44px; font-size: 15.5px; }
.x { flex: none; width: 36px; height: 36px; border: 0; background: none; color: var(--ink3); font-size: 20px; }
.add { width: 100%; height: 50px; border: 1.5px dashed var(--line2); border-radius: 12px; background: none; font-weight: 700; color: var(--ink2); }
.more { margin-top: 4px; }
.more summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink2); padding: 6px 0; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '+ '; font-family: var(--mono); }
.more[open] summary::before { content: '− '; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--ink3); }
.warn { margin: 12px var(--gut) 0; padding: 12px 14px; border-left: 4px solid var(--warn); background: #FBE9E6; font-size: 14.5px; color: #6E1A12; border-radius: 0 10px 10px 0; }
.warn b { color: var(--warn); }
.okbox { margin: 12px var(--gut) 0; padding: 12px 14px; border-left: 4px solid var(--ok); background: #E4F3EC; font-size: 14.5px; color: #0B4F37; border-radius: 0 10px 10px 0; }

/* 결과 */
.big { padding: 26px var(--gut) 6px; }
.big small { display: block; font-size: 14px; color: var(--ink3); font-weight: 600; }
.big b { display: block; font-size: 38px; line-height: 1.2; margin-top: 4px; }
.big p { margin: 6px 0 0; color: var(--ink2); font-size: 15px; }
.tabs { position: sticky; top: 56px; z-index: 15; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border-bottom: 1.5px solid var(--ink); margin-top: 14px; }
.tabs button { height: 48px; border: 0; background: none; font-weight: 700; font-size: 15px; color: var(--ink3); border-bottom: 3px solid transparent; margin-bottom: -1.5px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.moves { display: grid; gap: 10px; }
.move { background: var(--paper); border: 1.5px solid var(--ink); border-radius: 14px; padding: 14px 16px; }
.move.me { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.move-top { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.move-top .arrow { color: var(--ink3); font-family: var(--mono); }
.move-amt { margin-left: auto; font-size: 20px; }
.move-acc { margin-top: 10px; display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px dashed var(--line2); font-size: 13.5px; color: var(--ink2); }
.move-acc span { flex: 1; min-width: 0; }
.move-acc .num { font-size: 13.5px; }
.me-tag { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); padding: 1px 6px; border-radius: 4px; }

/* 전체 표 */
.tbl-wrap { overflow-x: auto; margin: 0 calc(var(--gut) * -1); padding: 0 var(--gut); -webkit-overflow-scrolling: touch; }
.tbl { border-collapse: separate; border-spacing: 0; min-width: 100%; font-size: 13.5px; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; }
.tbl th, .tbl td { padding: 10px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl th { font-size: 12px; color: var(--ink3); font-weight: 700; background: #F4F3EE; }
.tbl th.rc { color: #fff; }
.tbl td:first-child, .tbl th:first-child { text-align: left; position: sticky; left: 0; background: var(--paper); z-index: 1; border-right: 1px solid var(--line); }
.tbl th:first-child { background: #F4F3EE; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .absent { color: var(--line2); }
.tbl .skip { display: block; font-size: 10.5px; color: var(--warn); font-family: var(--sans); }
.tbl .pos { color: var(--ok); font-weight: 600; }
.tbl .neg { color: var(--warn); font-weight: 600; }
.tbl tfoot td { font-weight: 700; background: #F4F3EE; }
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }

/* 차수별 계산 근거 */
.calc { background: var(--paper); border: 1.5px solid var(--ink); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
.calc summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.calc summary::-webkit-details-marker { display: none; }
.calc .t-no { width: 38px; height: 38px; font-size: 13px; border-radius: 8px; }
.calc-body { padding: 0 16px 16px; border-top: 1.5px dashed var(--line2); }
.formula { margin: 12px 0 0; padding: 12px 14px; background: #F4F3EE; border-radius: 10px; font-size: 13.5px; line-height: 1.9; }
.formula div { display: flex; justify-content: space-between; gap: 10px; }
.formula .num { font-size: 13.5px; }
.kv { margin: 12px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--ink3); font-weight: 600; }
.kv dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note { margin: 10px 0 0; font-size: 13px; color: var(--warn); }

/* 기록 */
.log { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.log li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.log time { display: block; font-size: 12px; color: var(--ink3); font-family: var(--mono); }

/* 시안 표시줄 */
.proto { margin: 0; padding: 8px var(--gut); background: var(--ink); color: #fff; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.proto select { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: 3px 8px; font-size: 13px; }
.proto span { flex: 1; color: rgba(255,255,255,.7); }

/* 아래에서 올라오는 시트 */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(20,20,20,.45); }
.sheet-card { width: 100%; max-width: 480px; background: var(--bg); border-radius: 18px 18px 0 0; padding: 10px var(--gut) calc(20px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow: auto; animation: up .2s ease-out; }
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line2); margin: 2px auto 14px; }
.sheet h2 { margin: 0 0 6px; font-size: 21px; }
.sheet p { margin: 0 0 16px; color: var(--ink2); font-size: 15px; }
.share-link { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 14px; height: 52px; border: 1.5px solid var(--ink); border-radius: 12px; background: #fff; margin-bottom: 10px; }
.share-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13.5px; }
@keyframes up { from { transform: translateY(24px); opacity: .4; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--bar) + 18px + env(safe-area-inset-bottom)); transform: translate(-50%, 10px); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14.5px; opacity: 0; pointer-events: none; transition: .2s; z-index: 90; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { padding: 30px 0; text-align: center; color: var(--ink3); font-size: 15px; }
.foot { padding: 34px var(--gut) 10px; font-size: 12.5px; color: var(--ink3); }

/* 비슷한 이름 확인 */
.ask { margin-top: 14px; padding: 16px; border: 1.5px solid var(--ink); border-radius: 14px; background: var(--paper); display: grid; gap: 10px; }
.ask p { margin: 0; font-size: 16px; }
.ask .btn { height: 48px; font-size: 15.5px; }
/* 체크 전 사람 목록 */
.pends { margin-top: 10px; display: grid; gap: 6px; }
.pend { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(255,255,255,.65); border-radius: 8px; flex-wrap: wrap; }
.pend b { color: var(--ink); font-size: 14.5px; }
.pend small { font-size: 12px; color: #8A3A31; }
.pend-acts { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }
.pend-acts i { font-style: normal; color: #C9A19B; }
.pend-acts .link { padding: 2px 0; font-size: 13.5px; }
