/* base.css — 공용 스타일 (core, 화면 모듈은 수정 금지. 화면 전용은 css/screens/<group>.css)
   Theme.swift Palette → CSS 변수. 라이트 전용. iOS 느낌(리스트/시트/세그먼트/탭바). */

:root {
  color-scheme: light only;
  --ink: #1A1A1A;
  --ink2: #222222;
  --teal: #13C2A5;
  --blue: #4C6EF5;
  --red: #E05555;
  --redAlt: #E5484D;
  --orange: #F08C00;
  --field: #F5F5F7;
  --chip: #F0F0F2;
  --dim: #888888;
  --dim2: #AAAAAA;
  --dim3: #BBBBBB;
  --hair: #EEEEEE;
  --sun: #E05555;
  --sat: #5570E0;
  --gray6: #666666;
  --gray9: #999999;
  --bg-grouped: #F6F6F8;
  --stat0: #13C2A5; --stat1: #4C6EF5; --stat2: #FF922B; --stat3: #F06595; --stat4: #9775FA;
  --stat5: #20C997; --stat6: #FAB005; --stat7: #FF6B6B; --stat8: #748FFC; --stat9: #94D82D;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --tabbar-h: 50px;
  --nav-h: 44px;
  --content-max: 640px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
/* 빠르게 두 번 탭(계산기 '0','0', ▲▼ 순서 버튼, 달력 날짜 등)해도 화면이 확대되지 않게 (SwiftUI 처럼).
   두 손가락 확대·스크롤은 그대로. 화면별 pan-y / none 지정(클래스 선택자)이 이 값보다 우선합니다. */
* { touch-action: manipulation; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #fff; color: var(--ink2);
  font-family: var(--font); font-size: 16px; line-height: 1.3;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
/* iOS 는 16px 미만 입력칸 포커스 시 화면을 확대하므로 입력칸은 최소 16px */
input, textarea, select { font-size: 16px; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; flex: none; }

/* ───────────── 앱 골격 ───────────── */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: #fff; padding-top: var(--safe-top); padding-left: var(--safe-left); padding-right: var(--safe-right); }
.boot-spinner { flex: 1; display: flex; align-items: center; justify-content: center; }
.main-shell { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tab-views { position: relative; flex: 1; min-height: 0; }
.tab-view { position: absolute; inset: 0; overflow: hidden; background: #fff; }
.tab-view:not(.active) { display: none; }
/* 화면 모듈이 받는 루트 el: 세로 flex, 내부 스크롤은 화면이 결정 (.scroll 사용) */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: #fff; overflow: hidden; }
.screen-inner { width: 100%; max-width: var(--content-max); margin: 0 auto; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
.placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--dim2); font-size: 15px; text-align: center; padding: 40px; }

/* 탭바 (MainTabView) */
.tabbar {
  flex: none; display: flex; background: #fff; border-top: 0.5px solid rgba(0,0,0,0.15);
  padding-bottom: var(--safe-bottom); height: calc(var(--tabbar-h) + var(--safe-bottom));
}
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; padding-top: 5px; color: #999; font-size: 10px; font-weight: 500; }
.tab-btn.active { color: var(--teal); }
.tab-btn .icon svg { width: 25px; height: 25px; }

/* 푸시 페이지 (NavigationLink) */
.page { position: absolute; inset: 0; z-index: 5; background: #fff; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1); box-shadow: -8px 0 24px rgba(0,0,0,.06); }
.page.in { transform: none; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; position: relative; }

/* ───────────── 네비게이션 바 ───────────── */
.nav-bar { flex: none; height: var(--nav-h); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 8px; background: #fff; position: relative; }
.nav-title { font-size: 17px; font-weight: 600; color: var(--ink2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.nav-left { justify-content: flex-start; }
.nav-right { justify-content: flex-end; }
.nav-btn { display: inline-flex; align-items: center; gap: 2px; height: 44px; padding: 0 8px; font-size: 17px; color: var(--teal); white-space: nowrap; }
.nav-btn.bold { font-weight: 700; }
.nav-btn:disabled { color: var(--dim3) !important; }
.nav-btn:active { opacity: .5; }
.page-nav .nav-left .nav-btn { padding-left: 0; }
.nav-bar.large { height: auto; grid-template-columns: 1fr auto; grid-template-rows: var(--nav-h) auto; padding-bottom: 6px; }
.nav-bar.large .nav-left { grid-row: 1; grid-column: 1; }
.nav-bar.large .nav-right { grid-row: 1; grid-column: 2; }
.nav-bar.large .nav-title { grid-row: 2; grid-column: 1 / 3; text-align: left; font-size: 34px; font-weight: 700; padding: 0 8px; max-width: none; color: var(--ink); }

/* ───────────── 시트 (아래에서 올라오는 모달) ───────────── */
#overlay-root { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.sheet-layer { position: fixed; inset: 0; pointer-events: auto; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background .3s; }
.sheet-layer.open .sheet-backdrop { background: rgba(0,0,0,.35); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; width: 100%; max-width: 700px;
  height: calc(100% - var(--safe-top) - 10px);
  border-radius: 12px 12px 0 0; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(105%); transition: transform .34s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -4px 30px rgba(0,0,0,.12);
}
.sheet-layer.open .sheet { transform: translateY(0); }
.sheet-custom { max-height: calc(100% - var(--safe-top) - 10px); }
.sheet-grabber { flex: none; height: 14px; display: flex; align-items: center; justify-content: center; }
.sheet-grabber::after { content: ""; width: 36px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.18); }
.sheet-nav { background: transparent; margin-top: -6px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding-bottom: var(--safe-bottom); position: relative; }

/* ───────────── 알림 / 액션 시트 / 입력 알림 ───────────── */
.dialog-layer { position: fixed; inset: 0; pointer-events: auto; display: flex; align-items: center; justify-content: center; }
.dialog-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background .2s; }
.dialog-layer.open .dialog-backdrop { background: rgba(0,0,0,.4); }
.alert-box {
  position: relative; width: 270px; max-height: 80vh; display: flex; flex-direction: column;
  background: rgba(250,250,250,.97); border-radius: 14px; overflow: hidden;
  transform: scale(1.12); opacity: 0; transition: transform .2s, opacity .2s;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.dialog-layer.open .alert-box { transform: scale(1); opacity: 1; }
.dialog-layer.closing .alert-box { transform: scale(1); opacity: 0; }
.alert-content { padding: 19px 16px 16px; text-align: center; overflow-y: auto; }
.alert-title { font-size: 17px; font-weight: 600; color: #000; line-height: 1.3; }
.alert-message { margin-top: 4px; font-size: 13px; color: #000; line-height: 1.38; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
.alert-input { margin-top: 14px; width: 100%; height: 34px; padding: 0 8px; border: 0.5px solid rgba(0,0,0,.25); border-radius: 7px; background: #fff; outline: none; }
.alert-buttons { display: flex; flex-direction: column; border-top: 0.5px solid rgba(0,0,0,.2); flex: none; }
.alert-buttons.two { flex-direction: row; }
.alert-btn { flex: 1; height: 44px; font-size: 17px; color: var(--teal); }
.alert-buttons.two .alert-btn + .alert-btn { border-left: 0.5px solid rgba(0,0,0,.2); }
.alert-buttons:not(.two) .alert-btn + .alert-btn { border-top: 0.5px solid rgba(0,0,0,.2); }
.alert-btn.cancel { font-weight: 600; }
.alert-btn.destructive { color: #FF3B30; }
.alert-btn:active { background: rgba(0,0,0,.06); }

.dialog-layer:has(.action-sheet) { align-items: flex-end; }
.action-sheet { position: relative; width: 100%; max-width: 500px; padding: 0 8px calc(8px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; transform: translateY(110%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.dialog-layer.open .action-sheet { transform: none; }
.dialog-layer.closing .action-sheet { transform: translateY(110%); }
.as-group { background: rgba(250,250,250,.97); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.as-header { padding: 14px 16px; text-align: center; border-bottom: 0.5px solid rgba(0,0,0,.15); }
.as-title { font-size: 13px; font-weight: 600; color: #8a8a8e; }
.as-message { font-size: 13px; color: #8a8a8e; margin-top: 4px; white-space: pre-wrap; }
.as-btn { height: 57px; font-size: 20px; color: var(--teal); }
.as-btn + .as-btn { border-top: 0.5px solid rgba(0,0,0,.15); }
.as-btn.destructive { color: #FF3B30; }
.as-cancel { font-weight: 600; background: #fff; }
.as-btn:active { background: rgba(0,0,0,.06); }

/* ───────────── 공용 텍스트/색 유틸 ───────────── */
.c-ink { color: var(--ink); } .c-ink2 { color: var(--ink2); } .c-teal { color: var(--teal); } .c-blue { color: var(--blue); }
.c-red { color: var(--red); } .c-redAlt { color: var(--redAlt); } .c-orange { color: var(--orange); }
.c-dim { color: var(--dim); } .c-dim2 { color: var(--dim2); } .c-dim3 { color: var(--dim3); } .c-gray6 { color: var(--gray6); } .c-gray9 { color: var(--gray9); }
.bg-field { background: var(--field); } .bg-chip { background: var(--chip); } .bg-grouped { background: var(--bg-grouped); }
.fs-9 { font-size: 9px; } .fs-10 { font-size: 10px; } .fs-11 { font-size: 11px; } .fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; }
.fs-14 { font-size: 14px; } .fs-15 { font-size: 15px; } .fs-16 { font-size: 16px; } .fs-18 { font-size: 18px; } .fs-20 { font-size: 20px; }
.fs-22 { font-size: 22px; } .fs-24 { font-size: 24px; } .fs-30 { font-size: 30px; }
.bold { font-weight: 700; } .semibold { font-weight: 600; } .regular { font-weight: 400; }
.nowrap { white-space: nowrap; } .ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pre { white-space: pre-wrap; } .center { text-align: center; } .right { text-align: right; }
.row { display: flex; flex-direction: row; align-items: center; min-width: 0; }
.row.top { align-items: flex-start; } .row.baseline { align-items: baseline; }
.col { display: flex; flex-direction: column; min-width: 0; }
.spacer { flex: 1; }
.gap-2 { gap: 2px; } .gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; } .gap-18 { gap: 18px; } .gap-20 { gap: 20px; }
.p-12 { padding: 12px; } .p-14 { padding: 14px; } .p-16 { padding: 16px; } .p-20 { padding: 20px; }
.px-16 { padding-left: 16px; padding-right: 16px; } .px-20 { padding-left: 20px; padding-right: 20px; }
.divider { height: 0.5px; background: rgba(0,0,0,.12); flex: none; }
.divider.hair { background: var(--hair); height: 1px; }
.section-gap { height: 8px; background: var(--field); flex: none; }

/* ───────────── 버튼 ───────────── */
/* 검정 알약 버튼 (로그인, 가계부 등록 …) */
.btn-primary { display: flex; align-items: center; justify-content: center; width: 100%; height: 50px; border-radius: 24px; background: var(--ink); color: #fff; font-size: 16px; font-weight: 600; }
.btn-primary:disabled { opacity: .5; }
.btn-primary:active { opacity: .85; }
/* 빨간 테두리 (삭제/로그아웃) */
.btn-outline-red { display: flex; align-items: center; justify-content: center; width: 100%; height: 48px; border: 1px solid var(--red); border-radius: 12px; color: var(--red); font-size: 16px; }
.btn-outline-red.pill { height: 50px; border-radius: 24px; }
.btn-outline-red:active { background: rgba(224,85,85,.06); }
/* 설정의 목록 버튼 (listButton) */
.btn-list { display: flex; align-items: center; justify-content: center; width: 100%; height: 48px; border-radius: 12px; background: var(--field); color: var(--ink2); font-size: 16px; }
.btn-list:active { background: var(--chip); }
/* 작은 알약 (충전/수정 등) */
.btn-small { display: inline-flex; align-items: center; justify-content: center; padding: 5px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.btn-small.teal { background: var(--teal); color: #fff; }
.btn-small.outline { border: 1px solid var(--dim3); color: var(--ink2); }
.btn-text { color: var(--teal); font-size: 16px; padding: 6px 4px; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; padding: 8px; color: var(--ink2); }
.btn-icon:active, .btn-text:active, .btn-list:active { opacity: .6; }

/* 지출/수입/이체 같은 나란한 선택 버튼 (ui.typeButtons) */
.type-buttons { display: flex; width: 100%; }
.type-btn { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--chip); color: var(--dim); }
.type-btn.on { background: var(--on, var(--ink)); color: #fff; }

/* 칩 */
.chip { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; border: 1px solid #E5E5E8; font-size: 11px; color: var(--dim); }

/* ───────────── 입력 ───────────── */
.field { display: block; width: 100%; padding: 12px; border: 0; border-radius: 8px; background: var(--field); color: var(--ink2); font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; }
textarea.field { resize: none; line-height: 1.35; }
.field::placeholder, .alert-input::placeholder { color: #C4C4C8; }
.field-label { font-size: 13px; color: var(--dim); }
.field-group { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.date-input { -webkit-appearance: none; appearance: none; border: 0; background: var(--chip); color: var(--ink2); font-size: 16px; padding: 7px 12px; border-radius: 8px; min-height: 36px; width: auto; }
.date-input::-webkit-date-and-time-value { text-align: left; }
.select-menu { position: relative; display: flex; align-items: center; justify-content: center; padding: 10px 8px; border-radius: 8px; background: var(--field); color: var(--ink2); font-size: 14px; min-width: 0; }
.select-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.select-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; -webkit-appearance: none; appearance: none; border: 0; }

/* iOS 스위치 */
.switch { -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 51px; height: 31px; margin: 0; border-radius: 16px; background: #E9E9EB; transition: background .2s; cursor: pointer; outline: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform .2s; }
.switch:checked { background: var(--teal); }
.switch:checked::after { transform: translateX(20px); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 31px; width: 100%; cursor: pointer; }
.toggle-label { font-size: 17px; color: var(--ink2); }

/* SelectorRow */
.selector-row { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.selector-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border-radius: 10px; background: var(--field); text-align: left; }
.selector-icon { font-size: 20px; width: 26px; text-align: center; }
.selector-value { flex: 1; font-size: 16px; color: var(--ink2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selector-value.empty { color: var(--dim2); }
.selector-chev { font-size: 20px; color: #CCC; }

/* ───────────── 리스트 / 카드 ───────────── */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 44px; text-align: left; width: 100%; }
.list-row:active, .tap:active { background: rgba(0,0,0,.04); }
.list-row + .list-row { border-top: 0.5px solid rgba(0,0,0,.1); }
.card { background: var(--field); border-radius: 14px; padding: 14px; }
.card-12 { background: var(--field); border-radius: 12px; padding: 12px; }
.empty-state { color: var(--dim2); text-align: center; padding: 24px 16px; white-space: pre-line; font-size: 16px; }

/* TxRowView */
.tx-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer; }
.tx-row:active { background: rgba(0,0,0,.04); }
.tx-row-icon { flex: none; width: 34px; height: 34px; border-radius: 9px; background: var(--chip); color: var(--dim); font-size: 15px; display: flex; align-items: center; justify-content: center; }
.tx-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tx-row-line1 { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.tx-row-title { font-size: 15px; font-weight: 700; color: var(--ink2); white-space: nowrap; flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tx-row-memo { font-size: 11px; color: var(--dim3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tx-row-tags { font-size: 12px; color: var(--gray9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-row-amount { flex: none; font-size: 15px; font-weight: 700; }

/* SubAccountCardView */
.sub-card { background: #fff; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.sub-card-head { display: flex; align-items: center; gap: 8px; padding: 14px; text-align: left; width: 100%; }
.sub-card-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-card-balance { font-size: 16px; font-weight: 700; flex: none; }
.sub-card-divider { height: 1px; background: #F2F2F4; }
.sub-card-row { display: flex; align-items: center; gap: 8px; padding: 8px 14px; text-align: left; width: 100%; }
.sub-card-row.paused { opacity: .45; }
.sub-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sub-card-name { font-size: 14px; font-weight: 700; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-card-sub { font-size: 11.5px; color: var(--gray9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-card-amount { font-size: 14px; font-weight: 700; color: var(--ink2); flex: none; }
.sub-card-dday { font-size: 11.5px; font-weight: 700; width: 48px; text-align: right; flex: none; }
.sub-card-head:active, .sub-card-row:active { background: rgba(0,0,0,.03); }

/* ───────────── 플로팅 / 로딩 ───────────── */
.fab-top { position: absolute; right: 16px; bottom: 20px; z-index: 4; width: 46px; height: 46px; border-radius: 50%; background: rgba(26,26,26,.78); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.fab-top:active { transform: scale(.94); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid rgba(26,26,26,.15); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ptr-indicator { position: absolute; left: 50%; top: var(--ptr-top, 0); margin-left: -14px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; opacity: 0; z-index: 3; pointer-events: none; transition: opacity .15s; }
.ptr-indicator .spinner { animation: none; }
.ptr-indicator.spinning .spinner { animation: spin .8s linear infinite; }

/* ───────────── 로그인 ───────────── */
.login { flex: 1; overflow-y: auto; background: #fff; }
.login-inner { max-width: 420px; margin: 0 auto; padding: 80px 32px 40px; display: flex; flex-direction: column; gap: 16px; }
.login-title { font-size: 30px; font-weight: 700; color: var(--ink); text-align: center; }
.login-sub { font-size: 14px; color: var(--gray9); text-align: center; margin-bottom: 24px; }
.login .field { padding: 14px; }
.login-error { color: var(--red); font-size: 13px; }
.login-busy { display: flex; justify-content: center; padding-top: 8px; }
.mock-hint { font-size: 12px; color: var(--dim2); text-align: center; }
.mock-badge { position: fixed; top: calc(var(--safe-top) + 2px); left: 50%; transform: translateX(-50%); z-index: 3000; background: var(--orange); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 6px; pointer-events: none; opacity: .85; letter-spacing: .5px; }

/* ───────────── 계산기 ───────────── */
.calc-sheet .sheet-body { padding: 4px 16px calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; }
.calc-header { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.calc-cancel { color: var(--dim); font-size: 17px; padding: 6px 0; }
.calc-title { font-size: 16px; font-weight: 700; color: var(--ink2); }
.calc-done { color: var(--teal); font-size: 16px; font-weight: 700; padding: 6px 0; }
.calc-screen { background: var(--field); border-radius: 12px; padding: 16px; text-align: right; display: flex; flex-direction: column; gap: 2px; min-height: 84px; justify-content: flex-end; }
.calc-expr { font-size: 14px; color: var(--dim2); min-height: 17px; }
.calc-display { font-size: 34px; font-weight: 700; color: var(--ink2); white-space: nowrap; overflow: hidden; }
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 8px; }
.calc-key { height: 58px; border-radius: 14px; background: #F7F7F9; color: var(--ink2); font-size: 20px; }
.calc-key.wide { grid-column: span 2; }
.calc-key.fn { background: var(--chip); }
.calc-key.clear { color: var(--red); }
.calc-key.op { background: #E8EEFF; color: var(--blue); font-weight: 700; }
.calc-key.eq { background: var(--ink); color: #fff; font-weight: 700; }
.calc-key:active { filter: brightness(.93); }

/* ───────────── 이모지 / 격자 선택 ───────────── */
.emoji-auto-wrap { padding: 14px 20px; }
.emoji-auto { width: 100%; height: 46px; border-radius: 12px; background: var(--field); color: var(--ink2); font-size: 16px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 12px; justify-items: center; }
.emoji-cell { width: 52px; height: 52px; border-radius: 26px; background: var(--field); font-size: 24px; display: flex; align-items: center; justify-content: center; }
.emoji-cell.sel { background: #E8E8EC; box-shadow: inset 0 0 0 2px var(--ink); }
.picker-grid { display: grid; grid-template-columns: repeat(4, 1fr); row-gap: 24px; padding: 20px 12px; }
.picker-cell { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.picker-circle { width: 62px; height: 62px; border-radius: 31px; background: var(--field); font-size: 26px; display: flex; align-items: center; justify-content: center; }
.picker-cell.sel .picker-circle { background: #E8E8EC; box-shadow: inset 0 0 0 2px var(--ink); }
.picker-name { font-size: 12px; color: var(--gray6); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.picker-cell.sel .picker-name { font-weight: 700; color: var(--ink); }
.picker-empty { white-space: pre-line; text-align: center; color: var(--dim2); padding: 40px; }

/* ───────────── 휠 (MonthPicker) ───────────── */
.wheel { position: relative; display: flex; height: 180px; margin: 12px 24px; }
.wheel-highlight { position: absolute; left: 0; right: 0; top: 72px; height: 36px; border-radius: 8px; background: rgba(118,118,128,.12); pointer-events: none; }
.wheel-col { flex: 1; height: 180px; overflow-y: auto; scroll-snap-type: y mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent); }
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-pad { height: 72px; }
.wheel-item { height: 36px; line-height: 36px; text-align: center; font-size: 21px; color: var(--dim2); scroll-snap-align: center; cursor: pointer; }
.wheel-item.sel { color: #000; }

/* 768px 이상: 내용 폭 제한 (iPad/데스크톱에서도 보기 좋게) */
@media (min-width: 768px) {
  .screen-inner { max-width: var(--content-max); }
  .tabbar { justify-content: center; }
  .tab-btn { flex: 0 1 110px; }
  /* 탭 화면·푸시 페이지의 상단 바도 가운데 내용 열에 맞춤 (제목·버튼이 화면 양 끝으로 벌어지지 않게) */
  .screen > .nav-bar, .page > .nav-bar { padding-left: max(8px, calc((100% - var(--content-max)) / 2)); padding-right: max(8px, calc((100% - var(--content-max)) / 2)); }
}
