/* 정산데일리 — 방향과 토큰은 DESIGN.md */

@font-face {
  font-family: "Pretendard";
  src: url("fonts/PretendardVariable.woff2") format("woff2-variations"),
       url("fonts/PretendardVariable.woff2") format("woff2");
  font-weight: 45 920;
  font-style: normal;
  font-display: fallback;
}

:root {
  color-scheme: light dark;
  --canvas: #F2F3F6;
  --surface: #FFFFFF;
  --raised: #FFFFFF;
  --ink: #1A1D23;
  --ink-2: #4A505A;
  --ink-3: #636974;
  --ink-4: #878C96;
  --line: #E2E5E9;
  --fill: #F2F3F6;
  --fill-press: #E4E6EA;
  --seg-on: #FFFFFF;
  --press: rgba(26, 29, 35, .05);
  --grabber: #DCDFE4;
  --primary: #355EDD;
  --primary-press: #284CC3;
  --primary-ink: #355EDD;
  --primary-weak: #E5EFFF;
  --primary-weak-ink: #284CC3;
  --primary-dis: #CBDBFD;
  --primary-dis-ink: #5676C7;
  --seal: #CC3529;
  --seal-ink: #BA2C22;
  --seal-weak: #FFE9E5;
  --warn: #AA5910;
  --scrim: rgba(26, 29, 35, .45);
  --toast: rgba(26, 29, 35, .92);
  --toast-ink: #FFFFFF;
  --toast-act: #9DC0FF;
  --shadow-sheet: 0 -8px 32px rgba(26, 29, 35, .16);
  --shadow-pop: 0 16px 48px rgba(26, 29, 35, .2);
  --shadow-seg: 0 1px 4px rgba(26, 29, 35, .1);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23636974' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.5 9.5 5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  /* 도장 겹테두리·색 고르기 테두리의 빈칸: 놓인 면의 색 (시트 안에서는 --raised) */
  --paper: var(--surface);

  --r-chip: 10px;
  --r-ctl: 14px;
  --r-card: 20px;
  --r-sheet: 28px;
  --r-round: 999px;

  --tab-h: 60px;
  /* 앱(Capacitor)이 넣어 주는 값과 브라우저 env() 중 큰 쪽 */
  --st: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --sb: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --sl: max(env(safe-area-inset-left, 0px), var(--safe-area-inset-left, 0px));
  --sr: max(env(safe-area-inset-right, 0px), var(--safe-area-inset-right, 0px));

  /* 움직임: 시간·곡선은 당근 SEED 디자인 시스템 토큰(packages/rootage)을 그대로 쓴다 */
  --d1: 50ms; --d2: 100ms; --d3: 150ms; --d4: 200ms; --d5: 250ms; --d6: 300ms;
  --ease: cubic-bezier(.35, 0, .35, 1);
  --ease-enter: cubic-bezier(0, 0, .15, 1);
  --ease-exit: cubic-bezier(.35, 0, 1, 1);
  --ease-enter-x: cubic-bezier(.03, .4, .1, 1);
  --ease-exit-x: cubic-bezier(.35, 0, .95, .55);
  --ease-press: cubic-bezier(0, 0, .15, 1);
  /* 시트가 올라와 살짝(2%) 튕기고 멈추는 스프링 (질량 1, 강성 380, 감쇠 30). linear()를 모르면 SEED 곡선 */
  --spring: var(--ease-enter-x);
  --spring-dur: var(--d6);
  --z-tabbar: 10;
  --z-toast: 20;
}

@supports (animation-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, .0417, .1415, .2694, .4048, .5344, .6504, .749, .8293, .892, .9391, .9729, .9959, 1.0103, 1.0185, 1.0221, 1.0226, 1.0212, 1.0187, 1.0157, 1.0126, 1.0097, 1.0072, 1.0051, 1.0034, 1.0021, 1.0011, 1.0004, 1);
    --spring-dur: 450ms;
  }
}

/* 다크 모드: 같은 역할, 다른 값. 면은 위로 뜰수록 밝아지고(canvas < surface < raised < fill), 파란 글자는 밝은 쪽(--primary-ink)을 쓴다 */
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #111316;
    --surface: #1C1E22;
    --raised: #23252A;
    --ink: #EFF0F3;
    --ink-2: #C4C7CE;
    --ink-3: #A0A5AC;
    --ink-4: #787C83;
    --line: #303338;
    --fill: #33363B;
    --fill-press: #3D4045;
    --seg-on: #4A4D53;
    --press: rgba(255, 255, 255, .06);
    --grabber: #4A4D53;
    --primary: #3F69E2;
    --primary-press: #3258C8;
    --primary-ink: #80ADFF;
    --primary-weak: #1E2E56;
    --primary-weak-ink: #AECBFF;
    --primary-dis: #27324D;
    --primary-dis-ink: #7589B4;
    --seal: #EF5B53;
    --seal-ink: #F7857D;
    --seal-weak: #501F1B;
    --warn: #ECA760;
    --scrim: rgba(0, 0, 0, .6);
    --toast: #3F4248;
    --toast-ink: #EFF0F3;
    --toast-act: #AECBFF;
    --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, .5);
    --shadow-pop: 0 16px 48px rgba(0, 0, 0, .55);
    --shadow-seg: 0 1px 4px rgba(0, 0, 0, .3);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23A0A5AC' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.5 9.5 5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  /* 애플 기기는 시스템 글꼴(SF + Apple SD 산돌고딕 Neo). Pretendard가 바로 이 조합을 본뜬 글꼴이라 모양이 같고, 2MB를 내려받지 않아도 된다 */
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  font-variant-numeric: tabular-nums;
  font-synthesis: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--primary-ink); outline-offset: 2px; }
::selection { background: var(--primary-weak); color: var(--ink); }

.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 54px; padding: 0 20px; border-radius: var(--r-ctl);
  font-size: 17px; font-weight: 700;
  transition: transform var(--d3) var(--ease-press), background-color var(--d3) var(--ease), color var(--d3) var(--ease);
}
.btn:active { transform: scale(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-press); }
.btn-primary:disabled { background: var(--primary-dis); color: var(--primary-dis-ink); transform: none; cursor: default; }
.btn-secondary { background: var(--fill); color: var(--ink-2); }
.btn-secondary:active { background: var(--fill-press); }
.btn-weak { background: var(--primary-weak); color: var(--primary-weak-ink); }
.btn-danger { background: var(--seal-weak); color: var(--seal-ink); }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }
.btn-row > .btn-primary { flex: 1.6; }
.btn-block { width: 100%; }
.btn .ic { width: 20px; height: 20px; }

.text-btn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; border-radius: 10px;
  font-size: 15px; font-weight: 600; color: var(--primary-ink);
  transition: background-color var(--d3) var(--ease);
}
.text-btn:active { background: var(--press); }
.text-btn.is-danger { color: var(--seal-ink); }
.text-btn.is-sm { flex: none; margin-right: -8px; padding: 0 8px; font-size: 14px; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--ink-2);
  transition: background-color var(--d3) var(--ease);
}
.icon-btn:active { background: var(--fill-press); }

/* ---------- 화면 틀 ---------- */
.view {
  position: fixed; inset: 0 0 calc(var(--tab-h) + var(--sb));
  max-width: 520px; margin: 0 auto;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--st) + 4px) 16px 32px;
}
.page-head { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 8px 4px 12px; }
.page-head h1 { margin: 0; flex: 1; font-size: 26px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; }
.page-head h1 small { display: block; font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--ink-3); }
.head-act { display: flex; align-items: center; margin-left: auto; }

.card { background: var(--surface); border-radius: var(--r-card); padding: 20px; }
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px -8px 4px 0; }
.card-head .card-title { margin: 0; }
.card-title { margin: 0 0 6px; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.card-note { font-size: 14px; color: var(--ink-3); margin: 0 0 6px; }
.card-actions { margin-top: 18px; }
.card-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; color: var(--ink-2); }
.card-foot.is-tight { margin-top: 8px; padding-top: 0; border-top: 0; }
.card-foot b { color: var(--ink); font-weight: 700; white-space: nowrap; }
.card-foot b.is-due { color: var(--seal-ink); }

/* 금액 묶음: 화면마다 큰 숫자 하나 */
.money-label { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.money { margin-top: 2px; font-size: 32px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; }
.money.is-zero { color: var(--ink-4); }
.money-sub { margin-top: 4px; font-size: 14px; color: var(--ink-3); }
.money-sub.is-warn { color: var(--warn); font-weight: 600; }

/* ---------- 목록 ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 14px; width: calc(100% + 24px); min-height: 64px;
  margin: 0 -12px; padding: 10px 12px; border-radius: 14px; text-align: left;
  transition: background-color var(--d3) var(--ease);
}
button.row:active, label.row:active { background: var(--press); }
button.row > * { transition: transform var(--d3) var(--ease-press); }
button.row:active > * { transform: scale(.97); }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-size: 16px; font-weight: 600; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title.is-danger { color: var(--seal-ink); }
.row-sub { display: block; margin-top: 1px; font-size: 13px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub.is-wrap { margin-top: 2px; white-space: normal; line-height: 1.5; }
.row-sub.is-due { color: var(--seal-ink); font-weight: 600; }
.row-sub.is-part { color: var(--warn); font-weight: 600; }
.row-sub.is-run { color: var(--primary-ink); font-weight: 600; }
.row-end { flex: none; font-size: 16px; font-weight: 700; white-space: nowrap; }
.row-end.is-neg { color: var(--seal-ink); }
.row.is-skipped .row-title, .row.is-skipped .row-end { color: var(--ink-3); text-decoration: line-through; font-weight: 500; }
.row.is-paused .avatar { --c: var(--ink-3); }
.row.is-paused .row-title, .row.is-paused .row-end { color: var(--ink-3); }
.row-value { flex: none; font-size: 16px; font-weight: 600; color: var(--ink-2); }
.row-chev { width: 18px; height: 18px; color: var(--ink-4); margin-left: -6px; }
.empty-line { padding: 18px 0 10px; font-size: 15px; color: var(--ink-3); }
.empty-line .btn { margin-top: 14px; }

.avatar {
  flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  font-size: 17px; font-weight: 700; color: var(--c);
  background: var(--fill);
  background: color-mix(in srgb, var(--c) 11%, #fff);
}
@media (prefers-color-scheme: dark) {
  /* 어두운 바탕에서는 글자를 밝게, 바탕은 면 색에 섞는다 (글자 대비 6:1 이상) */
  .avatar {
    color: var(--ink);
    color: color-mix(in srgb, var(--c) 50%, #fff);
    background: color-mix(in srgb, var(--c) 26%, var(--surface));
  }
}
/* 아직 도장이 없는 달: 장부의 빈 도장 칸 */
.stamp-slot { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 2px dashed var(--line); }
.stamp-slot.is-due { border-color: var(--seal); }
.stamp-slot.is-part { border-color: var(--warn); }

/* ---------- 도장: 지급을 마치면 찍히는 이 앱의 표시 ---------- */
.stamp {
  --size: 64px;
  flex: none; display: inline-grid; place-items: center; width: var(--size); height: var(--size); border-radius: 50%;
  border: calc(var(--size) * .055) solid var(--seal);
  box-shadow: inset 0 0 0 calc(var(--size) * .035) var(--paper), inset 0 0 0 calc(var(--size) * .065) var(--seal);
  color: var(--seal); font-weight: 800; line-height: 1.05; text-align: center; letter-spacing: -.02em;
  font-size: max(11px, calc(var(--size) * .2));
  transform: rotate(-12deg);
  /* 인주가 덜 묻은 자리: 종이에 찍힌 질감 */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -9 6.4'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E") center / 160px 160px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -9 6.4'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E") center / 160px 160px;
}
.stamp.is-sm { --size: 42px; }
.stamp.is-lg { --size: 132px; }
/* 위에서 눌러 찍히는 한 번의 충격. 살짝 눌렸다 돌아오는 건 종이에 닿는 물리감이라 둔다 */
.stamp.is-pressing { animation: stamp-press .5s cubic-bezier(.3, 1.4, .5, 1) both; }
@keyframes stamp-press {
  0% { transform: translateY(-36px) rotate(-24deg) scale(1.6); opacity: 0; }
  55% { transform: translateY(0) rotate(-12deg) scale(.93); opacity: 1; }
  100% { transform: rotate(-12deg) scale(1); opacity: 1; }
}

/* 탭을 바꾸면 화면이 살짝 떠오르며 나타난다 */
.view:not([hidden]) { animation: view-in var(--d5) var(--ease-enter); }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 기록 화면 ---------- */
/* 날짜를 넘기면 넘긴 방향에서 들어오고(--from), 목록 줄은 차례로(--i) 떠오른다 */
.is-entering { animation: enter-x var(--d6) var(--ease-enter-x) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes enter-x { from { opacity: 0; transform: translate(var(--from, 0px), var(--rise, 8px)); } }
/* 방금 기록한 이름 줄: 파랗게 한 번 밝아졌다가 돌아온다 */
.row.is-bumped { animation: bump 1.1s var(--ease) both; }
@keyframes bump { 0%, 30% { background: var(--primary-weak); } 100% { background: transparent; } }
.row.is-bumped .row-end { animation: num-pop var(--d6) var(--ease-enter-x); }
@keyframes num-pop { 40% { transform: scale(1.08); } }
.view-today { padding-bottom: 0; }
.day-head { min-height: 56px; padding: 0 0 4px 4px; }
.date-btn {
  position: relative; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-left: -8px; padding: 0 8px; border-radius: 12px; cursor: pointer;
  font-size: 21px; font-weight: 700; letter-spacing: -.02em;
  transition: background-color var(--d3) var(--ease);
}
.date-btn:active { background: var(--fill-press); }
.date-btn .ic { width: 20px; height: 20px; color: var(--ink-3); }
.day-rel { flex: none; padding: 2px 8px; border-radius: var(--r-round); background: var(--primary-weak); color: var(--primary-weak-ink); font-size: 13px; font-weight: 700; }
.day-rel:empty { display: none; }
.date-btn input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  opacity: 0; font-size: 16px; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.date-btn input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; opacity: 0; cursor: pointer; }
.date-btn:has(input:focus-visible) { outline: 2px solid var(--primary-ink); outline-offset: 2px; }

.daycard { padding: 0; }
.money-block { padding: 18px 20px 16px; touch-action: pan-y; }
.pay-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; min-height: 36px; padding: 0 14px; border-radius: var(--r-round);
  background: var(--seal-weak); color: var(--seal-ink); font-size: 14px; font-weight: 700;
  transition: transform var(--d3) var(--ease-press);
}
.pay-pill:active { transform: scale(.97); }
.pay-pill.is-done { background: var(--fill); color: var(--ink-2); }
.pay-pill .ic { width: 16px; height: 16px; }
.view-today .card { padding-bottom: 10px; }
.view-today .card-title { margin-bottom: 2px; }
.entries .row { min-height: 58px; padding-top: 7px; padding-bottom: 7px; }
.entries .avatar { width: 38px; height: 38px; font-size: 16px; }
/* 이름별 목록: 줄은 그 사람 내역, 끝의 +는 그 이름으로 바로 기록 (누르는 칸은 44px, 보이는 원은 28px) */
.people .person { display: flex; align-items: center; }
.people .row { gap: 12px; flex: 1; width: auto; min-width: 0; margin-right: 0; }
.row-add {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: 0 -10px 0 2px; border-radius: 50%;
  transition: transform var(--d3) var(--ease-press);
}
.row-add > span {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary-weak); color: var(--primary-weak-ink);
}
.row-add:active { transform: scale(.92); }
.row-add .ic { width: 16px; height: 16px; stroke-width: 2.4; }
.people .empty-line { padding: 10px 0 8px; }

/* 사람 시트 */
.month-nav { display: flex; justify-content: space-between; margin: 6px -10px 0; }
.month-nav .text-btn { gap: 2px; }
.month-nav .text-btn .ic { width: 16px; height: 16px; }
.month-nav .text-btn:disabled { visibility: hidden; }
.owed-note {
  display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 14px; min-height: 44px; padding: 0 14px; border-radius: var(--r-ctl);
  background: var(--seal-weak); color: var(--seal-ink); font-size: 14px; font-weight: 700; text-align: left;
}
.owed-note span { flex: 1; }
.owed-note .ic { width: 16px; height: 16px; }
.sum-list .is-sub { padding-top: 0; font-size: 13px; color: var(--ink-3); }
.sum-list .is-sub b { color: var(--ink-3); font-weight: 600; }
.sum-list button.row-link { all: unset; display: flex; justify-content: space-between; gap: 12px; width: 100%; cursor: pointer; }

/* 바닥에 붙은 기록하기 버튼: 목록을 내려도 엄지 자리에 남는다 */
.rec-bar {
  position: sticky; bottom: 0; z-index: 1; margin: 0 -16px; padding: 16px 16px 12px;
  background: linear-gradient(to bottom, transparent, var(--canvas) 16px);
}
.rec-bar .btn { width: 100%; gap: 6px; }
.rec-bar .ic { width: 20px; height: 20px; stroke-width: 2.4; }

/* 키패드 시트 */
.pad { padding-top: 10px; }
.pad .grabber { margin-bottom: 12px; }
.pad-day { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--ink-3); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 14px; border-radius: var(--r-round);
  background: var(--fill); color: var(--ink-2); font-size: 15px; font-weight: 600; white-space: nowrap;
  transition: transform var(--d3) var(--ease-press), background-color var(--d3) var(--ease), color var(--d3) var(--ease);
}
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.chip.is-add { background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-3); }
.chip .ic { width: 16px; height: 16px; }

.amount-line { display: flex; align-items: center; gap: 10px; margin-top: 10px; min-height: 44px; }
.amount-value { flex: 1; min-width: 0; transform-origin: left center; font-size: 30px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amount-value.is-empty { color: var(--ink-4); }
.amount-value.is-neg { color: var(--seal-ink); }
.toggle {
  flex: none; min-height: 34px; padding: 0 12px; border-radius: var(--r-round);
  background: var(--fill); color: var(--ink-3); font-size: 14px; font-weight: 600;
  transition: background-color var(--d3) var(--ease), color var(--d3) var(--ease);
}
.toggle[aria-pressed="true"] { background: var(--seal-weak); color: var(--seal-ink); }
.amount-help { display: flex; align-items: center; min-height: 24px; font-size: 14px; color: var(--ink-3); }
.help-btn { min-height: 26px; padding: 0 2px; font-size: 14px; font-weight: 600; color: var(--primary-ink); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 2px; }
.quick button {
  min-height: 38px; border-radius: var(--r-chip); background: var(--fill); color: var(--ink-2); font-size: 15px; font-weight: 600;
  transition: transform var(--d3) var(--ease-press), background-color var(--d3) var(--ease);
}
.quick button:active { transform: scale(.96); background: var(--fill-press); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); }
.keys button {
  display: grid; place-items: center; height: 48px; border-radius: var(--r-ctl);
  font-size: 26px; font-weight: 500; color: var(--ink);
  -webkit-touch-callout: none;
  transition: background-color var(--d2) var(--ease), transform var(--d3) var(--ease-press);
}
.keys button:active { background: var(--fill); transform: scale(.92); }
.ic-key { width: 28px; height: 28px; stroke-width: 1.7; }
.cta { width: 100%; margin-top: 6px; }

/* ---------- 달력 ---------- */
.cal-card { padding: 16px 10px 10px; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-week span { padding-bottom: 8px; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.cal-week span:first-child { color: var(--seal-ink); }
.cal-week span:last-child { color: var(--primary-ink); }
.cal-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; min-height: 66px; padding: 4px 0 6px; border-radius: 14px;
  transition: background-color var(--d3) var(--ease);
}
button.cal-cell:active { background: var(--press); }
.cal-d { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 15px; font-weight: 600; }
.cal-cell.is-sun .cal-d { color: var(--seal-ink); }
.cal-cell.is-sat .cal-d { color: var(--primary-ink); }
.cal-cell.is-today .cal-d { background: var(--primary); color: #fff; }
.cal-cell.is-payday .cal-d { outline: 2px solid var(--seal); outline-offset: 1px; }
.cal-v { font-size: 11.5px; font-weight: 700; line-height: 1.3; color: var(--primary-ink); white-space: nowrap; }
.cal-v.is-neg { color: var(--seal-ink); }
.cal-v.is-skip { color: var(--ink-3); font-weight: 500; text-decoration: line-through; }
.cal-tag { font-size: 11px; font-weight: 700; line-height: 1.3; color: var(--seal-ink); }
.cal-tag.is-done { color: var(--ink-3); }

/* ---------- 정산 ---------- */
.settle-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.settle-top .stamp { margin: -4px -2px 0 0; }
.settle-card .btn-row { margin-top: 20px; }
.settle-people { margin-top: 22px; }
.settle-people .field-label { margin-bottom: 4px; }
.status { font-size: 13px; font-weight: 700; }

/* ---------- 설정 ---------- */
.switch { position: relative; flex: none; width: 52px; height: 32px; }
.switch input { position: absolute; inset: 0; z-index: 1; margin: 0; opacity: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: var(--r-round); background: var(--ink-4); transition: background-color var(--d4) var(--ease); }
.switch span::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(26, 29, 35, .2);
  transition: transform var(--d4) var(--ease);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary-ink); outline-offset: 2px; }
.row-time { flex: none; border: 0; background: var(--fill); border-radius: var(--r-chip); padding: 6px 10px; font-size: 16px; font-weight: 600; color: var(--ink); }

/* ---------- 탭 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 520px; height: calc(var(--tab-h) + var(--sb)); margin: 0 auto; padding-bottom: var(--sb);
  background: var(--surface); box-shadow: inset 0 1px 0 var(--line);
}
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.tabbar button .ic { width: 24px; height: 24px; color: var(--ink-4); }
.tabbar button[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tabbar button[aria-current="page"] .ic { color: var(--ink); stroke-width: 2.2; }
.tab-dot { position: absolute; top: 8px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--seal); box-shadow: inset 0 0 0 1.5px var(--surface); }

/* ---------- 바텀시트 ---------- */
dialog { color: var(--ink); }
/* 아이폰 Safari는 키보드가 떠도 화면 높이가 그대로라, device.js가 키보드 높이(--kb)만큼 시트를 올린다 */
.sheet {
  --paper: var(--raised);
  width: 100%; max-width: 520px; max-height: calc(100dvh - var(--st) - 16px - var(--kb, 0px));
  margin: auto auto var(--kb, 0px); padding: 0; border: 0; overflow-y: auto;
  background: var(--raised); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  /* 첫 그림자는 시트 아래로 이어 붙인 같은 색 면: 스프링으로 튕겨 올라가도 아래에 틈이 안 보인다 */
  box-shadow: 0 48px 0 var(--raised), var(--shadow-sheet);
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: sheet-in var(--spring-dur) var(--spring); }
.sheet[open]::backdrop { animation: fade-in var(--d6) var(--ease-enter); }
/* 끌어내리는 동안은 손가락을 따라오고(ui.js가 --drag에 내린 거리를 넣는다), 놓으면 스프링으로 돌아간다.
   한 번 끈 시트(is-still)는 올라오는 효과를 다시 틀지 않는다 */
.sheet.is-dragging, .sheet.is-still, .sheet.is-dragging::backdrop, .sheet.is-still::backdrop { animation: none; }
.sheet.is-dragging { transform: translateY(var(--drag, 0px)); }
.sheet.is-dragging::backdrop { opacity: calc(1 - var(--drag-k, 0)); }
.sheet.is-closing { animation: sheet-out var(--d4) var(--ease-exit) forwards; }
.sheet.is-closing::backdrop { animation: fade-out var(--d4) var(--ease-exit) forwards; }
.sheet.is-settling { transition: transform var(--spring-dur) var(--spring); }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet-body { padding: 10px 20px calc(16px + var(--sb)); }
/* frontend-apex-ignore: focus-outline-removed -- 열 때 키보드가 뜨지 않게 시트 본문에 주는 프로그램 포커스. 눌러서 갈 수 없는 자리라 표시할 게 없다 */
.sheet-body:focus { outline: none; }
.grabber { position: relative; width: 40px; height: 5px; margin: 0 auto 18px; border-radius: 3px; background: var(--grabber); touch-action: none; }
.grabber::before { content: ''; position: absolute; inset: -14px -60px; }
/* 손잡이와 맨 위 줄은 끌어내리기 전용 (브라우저 스크롤이 가로채지 않게) */
.sheet-kicker, .pad-day, .sheet > .sheet-body > .sheet-title:first-of-type { touch-action: none; }
.sheet-kicker { margin-bottom: 2px; font-size: 15px; font-weight: 600; color: var(--ink-3); }
.sheet-title { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -.02em; }
.sheet-sub { margin-top: 6px; font-size: 15px; color: var(--ink-3); }
.sheet-section { margin-top: 22px; }
.sheet-actions { position: sticky; bottom: 0; margin: 24px -20px 0; padding: 8px 20px 0; background: var(--raised); }
.sheet-links { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px -10px 0; }

.alert {
  --paper: var(--raised);
  width: min(340px, calc(100vw - 40px)); margin: auto; padding: 24px 20px 20px; border: 0; border-radius: 24px;
  background: var(--raised); box-shadow: var(--shadow-pop);
}
.alert::backdrop { background: var(--scrim); }
.alert[open] { animation: alert-in var(--d5) var(--ease-enter-x); }
@keyframes alert-in { from { transform: scale(.94); opacity: 0; } }
.alert .sheet-title { font-size: 20px; }
.alert .btn-row { margin-top: 24px; }
.alert .btn { min-height: 50px; }

/* 입력 */
.field { display: block; margin-top: 16px; }
.field-label { display: block; margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.big-input-help + .seg { margin-top: 8px; }
.input, .select {
  display: block; width: 100%; min-height: 52px; padding: 0 16px; border: 0; border-radius: var(--r-ctl);
  background: var(--fill); font-size: 17px; font-weight: 500; color: var(--ink); caret-color: var(--primary-ink);
  transition: background-color var(--d3) var(--ease);
}
.input::placeholder { color: var(--ink-3); }
.input:focus { background: var(--paper); }
.select {
  -webkit-appearance: none; appearance: none; padding-right: 44px;
  background: var(--fill) var(--chevron) no-repeat right 14px center;
}
.select:focus { background-color: var(--paper); }
/* 아이폰 Safari만: 날짜칸 글자를 왼쪽에 맞추고, 비어 있어도 높이를 지킨다 */
@supports (-webkit-touch-callout: none) {
  .input[type="date"] { -webkit-appearance: none; appearance: none; text-align: left; line-height: 52px; }
  .input[type="date"]::-webkit-date-and-time-value { text-align: left; }
}
.input:focus-visible, .select:focus-visible { outline-offset: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.grid2 .field { margin-top: 0; }

/* 큰 금액 입력 (지급·하루만 바꾸기) */
.big-input { display: flex; align-items: baseline; gap: 4px; margin-top: 18px; padding-bottom: 8px; border-bottom: 2px solid var(--line); transition: border-color var(--d3) var(--ease); }
.big-input:focus-within { border-color: var(--primary-ink); }
.big-input input { flex: 0 1 auto; field-sizing: content; min-width: 2ch; max-width: 100%; padding: 0; border: 0; background: none; font-size: 30px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); caret-color: var(--primary-ink); }
/* frontend-apex-ignore: focus-outline-removed -- 바로 위 .big-input:focus-within의 2px 파란 밑줄이 포커스 표시를 대신함 */
.big-input input:focus-visible { outline: none; }
.big-input span { font-size: 26px; font-weight: 700; color: var(--ink-2); }
.big-input-help { min-height: 22px; margin-top: 8px; font-size: 14px; color: var(--ink-3); }
/* 읽어 주는 금액 옆에 '금액 복사' */
.read-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.read-row .big-input-help { margin-top: 0; }

.seg { display: flex; padding: 4px; border-radius: var(--r-ctl); background: var(--fill); }
.seg label { position: relative; flex: 1; display: grid; place-items: center; min-height: 42px; border-radius: 11px; font-size: 15px; font-weight: 600; color: var(--ink-3); cursor: pointer; transition: background-color var(--d3) var(--ease), color var(--d3) var(--ease); }
.seg input, .days input, .swatches input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--seg-on); color: var(--ink); box-shadow: var(--shadow-seg); }
.seg label:has(input:focus-visible), .days label:has(input:focus-visible), .swatches label:has(input:focus-visible) { outline: 2px solid var(--primary-ink); outline-offset: 2px; }
.days { display: flex; justify-content: space-between; gap: 4px; }
.days label { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--fill); font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: background-color var(--d3) var(--ease), color var(--d3) var(--ease); }
.days label:has(input:checked) { background: var(--primary); color: #fff; }
.presets { display: flex; gap: 6px; margin-top: 10px; }
.presets .chip { min-height: 32px; font-size: 14px; }
.swatches { display: flex; gap: 12px; }
.swatches label { width: 32px; height: 32px; border-radius: 50%; background: var(--c); cursor: pointer; }
.swatches label:has(input:checked) { box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 5px var(--c); outline: 2px solid var(--c); outline-offset: 1px; }
.day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 20px; }
.day-grid button { height: 44px; border-radius: 12px; background: var(--fill); font-size: 16px; font-weight: 600; color: var(--ink-2); transition: transform var(--d3) var(--ease-press); }
.day-grid button:active { transform: scale(.94); }
.day-grid button[aria-pressed="true"] { background: var(--primary); color: #fff; }
.day-grid .is-wide { grid-column: span 2; }

.sum-list { list-style: none; margin: 18px 0 0; padding: 0; }
.sum-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 15px; color: var(--ink-2); }
.sum-list li b { color: var(--ink); font-weight: 600; white-space: nowrap; }
.sum-list .is-total { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 17px; font-weight: 700; color: var(--ink); }
.sum-list .is-total b { font-weight: 700; }
.sum-list small { font-size: 13px; color: var(--ink-3); }

.steps { list-style: none; margin: 20px 0 0; padding: 0; counter-reset: step; }
.steps li { position: relative; min-height: 32px; padding: 4px 0 12px 44px; font-size: 16px; line-height: 1.5; color: var(--ink-2); counter-increment: step; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-weak); color: var(--primary-weak-ink); font-size: 15px; font-weight: 700;
}
.steps b { color: var(--ink); font-weight: 700; }

/* 지급 완료 화면 */
.done { display: flex; flex-direction: column; align-items: center; padding: 18px 0 6px; text-align: center; }
.done .sheet-title { margin-top: 26px; white-space: pre-line; }
.done .sheet-sub { margin-top: 8px; }

/* ---------- 알림 메시지 ---------- */
/* 엄지 가까이 아래에 뜬다: 기록 화면은 키패드 바로 위(ui.js가 bottom을 정함), 시트가 열려 있으면 위.
   popover로 띄워서 열린 시트 위에도 보인다. 아래 inset·margin·border는 popover 기본 모양을 덮는 값 */
.toast {
  position: fixed; inset: auto 0 calc(var(--tab-h) + var(--sb) + 12px); z-index: var(--z-toast);
  display: flex; align-items: center; gap: 12px;
  width: fit-content; max-width: min(calc(100% - 32px), 440px); margin: 0 auto; padding: 12px 18px; border: 0; border-radius: 16px; overflow: visible;
  background: var(--toast); color: var(--toast-ink); font-size: 15px; font-weight: 500; line-height: 1.45;
  opacity: 0; transform: scale(.8); pointer-events: none;
  transition: opacity var(--d2) var(--ease-exit), transform var(--d2) var(--ease-exit);
}
.toast.is-on { transition-duration: var(--d3); transition-timing-function: var(--ease-enter); }
.toast[data-at="top"] { top: calc(var(--st) + 10px); bottom: auto; }
.toast.is-on { opacity: 1; transform: none; }
.toast.has-action { padding-right: 8px; }
.toast.has-action.is-on { pointer-events: auto; }
.toast-act {
  flex: none; min-height: 40px; margin: -8px 0; padding: 0 10px; border-radius: 10px;
  color: var(--toast-act); font-weight: 700;
  transition: background-color var(--d3) var(--ease);
}
.toast-act:active { background: rgba(255, 255, 255, .12); }

/* ---------- 작은 화면 ---------- */
@media (max-height: 700px) {
  .money-block { padding: 14px 20px 12px; }
  .money { font-size: 28px; }
  .keys button { height: 44px; }
}
@media (max-height: 600px) {
  :root { --tab-h: 54px; }
  .day-head { min-height: 44px; padding-bottom: 2px; }
  .date-btn { min-height: 38px; font-size: 18px; }
  .money-block { padding: 12px 16px 10px; }
  .money-label { font-size: 14px; }
  .money { font-size: 26px; }
  .rec-bar { padding-top: 12px; padding-bottom: 8px; }
  .rec-bar .btn { min-height: 50px; }
  .pad .grabber { margin-bottom: 8px; }
  .pad-day { margin-bottom: 6px; }
  .amount-line { margin-top: 6px; }
  .amount-value { font-size: 26px; }
  .quick button { min-height: 34px; }
  .tabbar button { gap: 1px; }
}
@media (min-width: 560px) {
  .tabbar { box-shadow: inset 0 1px 0 var(--line), inset 1px 0 0 var(--line), inset -1px 0 0 var(--line); }
}

/* ---------- 가로 화면: 웹으로 연 폰을 눕혔을 때 (안드로이드 앱은 세로 고정) ----------
   탭은 왼쪽 세로 줄로, 키패드 시트는 왼쪽 금액 · 오른쪽 숫자 키 두 칸으로 */
@media (orientation: landscape) and (max-height: 540px) {
  :root { --rail: calc(64px + var(--sl)); }
  .tabbar {
    top: 0; right: auto; width: var(--rail); height: auto; max-width: none; margin: 0;
    grid-template-columns: none; grid-template-rows: repeat(4, 64px); align-content: center;
    padding: var(--st) 0 var(--sb) var(--sl);
    box-shadow: inset -1px 0 0 var(--line);
  }
  .view {
    inset: 0 0 0 var(--rail); max-width: none; margin: 0;
    padding: calc(var(--st) + 4px) calc(20px + var(--sr)) calc(16px + var(--sb)) 20px;
  }
  .view > * { max-width: 560px; margin-inline: auto; }
  .view-today { padding-bottom: 0; }
  .view-today > .rec-bar { max-width: none; margin-inline: -20px; padding-inline: 20px; }
  .rec-bar .btn { display: flex; max-width: 560px; margin-inline: auto; }
  .day-head { flex-wrap: wrap; row-gap: 0; }
  .pay-pill { margin-top: 8px; }
  .cal-cell { min-height: 54px; }
  /* 키패드 시트는 두 칸: 왼쪽 이름·금액·기록하기, 오른쪽 숫자 키 */
  .pad-sheet { max-width: min(680px, 100vw); }
  .pad {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; align-content: start;
    grid-template-areas: "grab grab" "day keys" "chips keys" "amount keys" "help keys" "quick keys" "cta keys";
    padding-left: calc(20px + var(--sl)); padding-right: calc(20px + var(--sr));
  }
  .pad .grabber { grid-area: grab; margin-bottom: 6px; }
  .pad-day { grid-area: day; margin-bottom: 4px; }
  .pad .chips { grid-area: chips; margin: 0; padding: 2px 0; }
  .amount-line { grid-area: amount; margin-top: 4px; }
  .amount-help { grid-area: help; }
  .quick { grid-area: quick; }
  .pad .cta { grid-area: cta; align-self: end; }
  .keys { grid-area: keys; align-self: center; }
  .keys button { height: 44px; }
  .toast { inset: auto 0 calc(var(--sb) + 16px) var(--rail); }
  .toast[data-at="top"] { inset: calc(var(--st) + 10px) 0 auto; }
}
/* 좁은 가로 화면(아이폰 SE): 날짜 줄이 한 줄에 들어가게 */
@media (orientation: landscape) and (max-height: 540px) and (max-width: 700px) {
  .day-rel { display: none; }
}
/* Safari 주소창까지 있는 가로 화면(높이 320~360px): 키패드가 넘치지 않게 한 번 더 줄인다 */
@media (orientation: landscape) and (max-height: 360px) {
  .keys button { height: 36px; font-size: 22px; }
  .rec-bar { padding-top: 10px; padding-bottom: 8px; }
  .rec-bar .btn, .btn.cta { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .sheet[open], .sheet[open]::backdrop, .sheet.is-closing, .sheet.is-closing::backdrop, .alert[open], .stamp.is-pressing,
  .view:not([hidden]), .is-entering, .row.is-bumped { animation: none; }
  .sheet.is-settling { transition: none; }
  .btn:active, .chip:active, .quick button:active, .pay-pill:active, .day-grid button:active, .keys button:active, button.row:active > * { transform: none; }
  .toast { transition: opacity var(--d3) var(--ease); transform: none; }
}
