/* ==========================================================================
   우리집 공동 가계부 — iOS 26 "Liquid Glass" 디자인 시스템
   레이어 규칙: L0 벽지(필터 없음) · L1 스크롤 카드(blur만) ·
                L2 고정 바(blur+굴절 18) · L3 시트/메뉴/토스트(blur+굴절 30)
   ========================================================================== */

@font-face {
  font-family: "Pretendard Variable";
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
  src: url("pretendard-variable.woff2") format("woff2-variations");
}

/* ===== 토큰: 라이트(기본) ===== */
:root {
  color-scheme: light;

  /* 브랜드 색 — 변경 금지 */
  --income: #42c99a;
  --income-top: #4fd8a6;
  --expense: #30343d;
  --saving: #5288e8;
  --transfer: #9aa1ad;
  --red: #ff777c;
  --yellow: #ffc64d;
  --blue: #5288e8;
  --on-accent: #0f2b22;

  /* 장부 색 */
  --ledger-husband: #5288e8;
  --ledger-wife: #c9a0dc;
  --ledger-shared: #42c99a;
  --ledger-all: #30343d;

  /* 벽지 */
  --wall: linear-gradient(165deg, #f3f6fb, #e9edf5 55%, #f2eef6);
  --wall2: radial-gradient(64% 40% at 10% 5%, rgba(66, 201, 154, 0.34), transparent 70%),
    radial-gradient(58% 36% at 98% 20%, rgba(82, 136, 232, 0.3), transparent 70%),
    radial-gradient(74% 40% at 55% 104%, rgba(255, 198, 77, 0.24), transparent 70%);

  /* 텍스트 — 알파값을 낮추지 말 것(유리 위 AA 4.5:1 측정값) */
  --txt: #30343d;
  --txt2: rgba(48, 52, 61, 0.84);
  --txt3: rgba(48, 52, 61, 0.78);
  --ink: #30343d;
  --expense-ink: #30343d;
  --on-bg: #30343d;
  --on-fg: #ffffff;

  /* 유리 재질 */
  --lg-sat: 195%;
  --lg-blur-1: 12px;
  --lg-blur-2: 22px;
  --lg-blur-3: 34px;
  --lg-refract-2: url("#lg-edge-2");
  --lg-refract-3: url("#lg-edge-3");
  --lg-s1: rgba(255, 255, 255, 0.6);
  --lg-s2: rgba(255, 255, 255, 0.66);
  --lg-s3: rgba(255, 255, 255, 0.8);
  --lg-stroke: color-mix(in oklab, currentColor 14%, transparent);
  --lg-hi: rgba(255, 255, 255, 0.92);
  --lg-lo: rgba(48, 52, 61, 0.09);
  --lg-shadow-1: 0 6px 16px rgba(40, 48, 66, 0.1);
  --lg-shadow-2: 0 14px 34px rgba(40, 48, 66, 0.16);
  --lg-shadow-3: 0 22px 54px rgba(40, 48, 66, 0.22);
  --lg-opaque-1: #f4f7fc;
  --lg-opaque-2: #ffffff;
  --lg-opaque-3: #ffffff;

  /* 표면 */
  --card: rgba(255, 255, 255, 0.6);
  --chip: rgba(255, 255, 255, 0.78);
  --key: rgba(255, 255, 255, 0.7);
  --stroke: rgba(255, 255, 255, 0.8);
  --spec: rgba(255, 255, 255, 0.95);
  --track: rgba(48, 52, 61, 0.1);
  --donut-hole: #ffffff;
  --expense-bar: #30343d;

  --font-sans: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", -apple-system, system-ui, sans-serif;
  --font-mono: ui-monospace, Menlo, Consolas, monospace;

  font-family: var(--font-sans);
}

/* ===== 토큰: 다크 ===== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --wall: linear-gradient(165deg, #1a1f27, #252c3a 60%, #2b2233);
  --wall2: radial-gradient(64% 40% at 10% 5%, rgba(66, 201, 154, 0.4), transparent 70%),
    radial-gradient(58% 36% at 98% 20%, rgba(82, 136, 232, 0.4), transparent 70%),
    radial-gradient(74% 40% at 55% 104%, rgba(255, 198, 77, 0.2), transparent 70%);

  --txt: #ffffff;
  --txt2: rgba(255, 255, 255, 0.84);
  --txt3: rgba(255, 255, 255, 0.7);
  --ink: #ffffff;
  --expense-ink: #e7ebf3;
  --on-bg: rgba(255, 255, 255, 0.92);
  --on-fg: #20242e;

  --lg-s1: rgba(255, 255, 255, 0.17);
  --lg-s2: rgba(255, 255, 255, 0.16);
  --lg-s3: rgba(26, 30, 40, 0.74);
  --lg-stroke: color-mix(in oklab, currentColor 26%, transparent);
  --lg-hi: rgba(255, 255, 255, 0.44);
  --lg-lo: rgba(6, 9, 14, 0.24);
  --lg-shadow-1: 0 6px 18px rgba(9, 12, 19, 0.16);
  --lg-shadow-2: 0 14px 38px rgba(9, 12, 19, 0.34);
  --lg-shadow-3: 0 22px 58px rgba(6, 9, 14, 0.46);
  --lg-opaque-1: #262c37;
  --lg-opaque-2: #2c3341;
  --lg-opaque-3: #1f242f;

  --card: rgba(255, 255, 255, 0.09);
  --chip: rgba(255, 255, 255, 0.16);
  --key: rgba(255, 255, 255, 0.12);
  --stroke: rgba(255, 255, 255, 0.22);
  --spec: rgba(255, 255, 255, 0.38);
  --track: rgba(255, 255, 255, 0.15);
  --donut-hole: #232a36;
  --expense-bar: #c7cddb;
  --ledger-all: #7d92c7;
}

/* 시스템 다크 — 사용자가 라이트를 명시하지 않았을 때만 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --wall: linear-gradient(165deg, #1a1f27, #252c3a 60%, #2b2233);
    --wall2: radial-gradient(64% 40% at 10% 5%, rgba(66, 201, 154, 0.4), transparent 70%),
      radial-gradient(58% 36% at 98% 20%, rgba(82, 136, 232, 0.4), transparent 70%),
      radial-gradient(74% 40% at 55% 104%, rgba(255, 198, 77, 0.2), transparent 70%);

    --txt: #ffffff;
    --txt2: rgba(255, 255, 255, 0.84);
    --txt3: rgba(255, 255, 255, 0.7);
    --ink: #ffffff;
    --expense-ink: #e7ebf3;
    --on-bg: rgba(255, 255, 255, 0.92);
    --on-fg: #20242e;

    --lg-s1: rgba(255, 255, 255, 0.17);
    --lg-s2: rgba(255, 255, 255, 0.16);
    --lg-s3: rgba(26, 30, 40, 0.74);
    --lg-stroke: color-mix(in oklab, currentColor 26%, transparent);
    --lg-hi: rgba(255, 255, 255, 0.44);
    --lg-lo: rgba(6, 9, 14, 0.24);
    --lg-shadow-1: 0 6px 18px rgba(9, 12, 19, 0.16);
    --lg-shadow-2: 0 14px 38px rgba(9, 12, 19, 0.34);
    --lg-shadow-3: 0 22px 58px rgba(6, 9, 14, 0.46);
    --lg-opaque-1: #262c37;
    --lg-opaque-2: #2c3341;
    --lg-opaque-3: #1f242f;

    --card: rgba(255, 255, 255, 0.09);
    --chip: rgba(255, 255, 255, 0.16);
    --key: rgba(255, 255, 255, 0.12);
    --stroke: rgba(255, 255, 255, 0.22);
    --spec: rgba(255, 255, 255, 0.38);
    --track: rgba(255, 255, 255, 0.15);
    --donut-hole: #232a36;
    --expense-bar: #c7cddb;
    --ledger-all: #7d92c7;
  }
}

/* ===== 유리 폴백 1: backdrop-filter의 SVG url()을 못 쓰는 브라우저 ===== */
@supports not (backdrop-filter: url("#lg-edge-2")) {
  :root {
    --lg-refract-2: blur(0px);
    --lg-refract-3: blur(0px);
  }
}

/* ===== 유리 폴백 3: 투명도 줄이기 =====
   테마 블록(:root[data-theme="dark"] 등)보다 특이도가 낮으므로 !important로 확실히 덮는다.
   표면은 --txt를 섞어 불투명하게 만들어, 유리가 사라져도 카드 경계가 남는다. */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --lg-sat: 100% !important;
    --lg-blur-1: 0px !important;
    --lg-blur-2: 0px !important;
    --lg-blur-3: 0px !important;
    --lg-refract-2: blur(0px) !important;
    --lg-refract-3: blur(0px) !important;
    --lg-s1: var(--lg-opaque-1) !important;
    --lg-s2: var(--lg-opaque-2) !important;
    --lg-s3: var(--lg-opaque-3) !important;
    --lg-hi: transparent !important;
    --lg-lo: transparent !important;
    --card: color-mix(in srgb, var(--txt) 6%, var(--lg-opaque-1)) !important;
    --chip: color-mix(in srgb, var(--txt) 12%, var(--lg-opaque-1)) !important;
    --key: color-mix(in srgb, var(--txt) 8%, var(--lg-opaque-1)) !important;
    --stroke: color-mix(in srgb, var(--txt) 16%, transparent) !important;
    --spec: transparent !important;
  }
}

/* ===== 애니메이션 ===== */
@keyframes v2-pop {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes v2-sheet {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes v2-toast {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  12% {
    opacity: 1;
    transform: none;
  }
  85% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
  }
}

@keyframes v2-blink {
  0%,
  45% {
    opacity: 1;
  }
  55%,
  100% {
    opacity: 0.12;
  }
}

/* ===== 기본 ===== */
* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--wall);
  color: var(--txt);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--income);
  outline-offset: 2px;
}

.lg-filters {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ===== 유리 레이어 유틸리티 ===== */
.lg-1,
.lg-2,
.lg-3 {
  border: 1px solid var(--lg-stroke);
  corner-shape: squircle;
}

/* L1 — 스크롤 안쪽 카드. 굴절 필터 없음(GPU 비용) */
.lg-1 {
  background: var(--lg-s1);
  -webkit-backdrop-filter: saturate(var(--lg-sat)) blur(var(--lg-blur-1));
  backdrop-filter: saturate(var(--lg-sat)) blur(var(--lg-blur-1));
  box-shadow: var(--lg-shadow-1), inset 1px 1px 0 var(--lg-hi), inset -1px -1px 0 var(--lg-lo);
}

/* L2 — 고정 바(헤더·탭바) */
.lg-2 {
  background: var(--lg-s2);
  -webkit-backdrop-filter: saturate(var(--lg-sat)) blur(var(--lg-blur-2));
  backdrop-filter: saturate(var(--lg-sat)) blur(var(--lg-blur-2)) var(--lg-refract-2);
  box-shadow: var(--lg-shadow-2), inset 1px 1px 0 var(--lg-hi), inset -1px -1px 0 var(--lg-lo);
}

/* L3 — 시트·메뉴·토스트 */
.lg-3 {
  background: var(--lg-s3);
  -webkit-backdrop-filter: saturate(var(--lg-sat)) blur(var(--lg-blur-3));
  backdrop-filter: saturate(var(--lg-sat)) blur(var(--lg-blur-3)) var(--lg-refract-3);
  box-shadow: var(--lg-shadow-3), inset 1px 1px 0 var(--lg-hi), inset -1px -1px 0 var(--lg-lo);
}

/* ===== 셸 ===== */
.workspace {
  display: grid;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  padding: 2rem;
}

.phone {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 402px);
  height: min(874px, calc(100dvh - 4rem));
  min-height: 560px;
  overflow: hidden;
  border-radius: 44px;
  corner-shape: squircle;
  background: var(--wall);
  box-shadow: 0 40px 90px rgba(20, 26, 40, 0.28);
  color: var(--txt);
}

.wall {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--wall);
  pointer-events: none;
}

.wall--tint {
  background: var(--wall2);
}

.page-scroll {
  position: relative;
  z-index: 10;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 2px 16px 8px;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.page-scroll::-webkit-scrollbar {
  display: none;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: v2-pop 0.35s ease;
}

.page[hidden] {
  display: none;
}

.scroll-tail {
  height: 110px;
  flex: none;
}

/* ===== 헤더 (L2) ===== */
.app-header {
  position: relative;
  z-index: 20;
  flex: none;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 10px;
}

.app-header__glass {
  padding: 12px 14px 14px;
  border-radius: 30px;
}

.app-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.app-title {
  margin: 0;
  color: var(--txt);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.sync-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid rgba(66, 201, 154, 0.32);
  border-radius: 12px;
  background: rgba(66, 201, 154, 0.16);
  color: var(--txt2);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.sync-chip__dot {
  flex: none;
  width: 5px;
  height: 5px;
  border-radius: 6px;
  background: var(--income);
}

.sync-chip[data-state="syncing"] {
  border-color: rgba(255, 198, 77, 0.36);
  background: rgba(255, 198, 77, 0.16);
}

.sync-chip[data-state="syncing"] .sync-chip__dot {
  background: var(--yellow);
}

.sync-chip[data-state="offline"],
.sync-chip[data-state="error"],
.sync-chip[data-state="unauthorized"] {
  border-color: rgba(255, 119, 124, 0.34);
  background: rgba(255, 119, 124, 0.14);
}

.sync-chip[data-state="offline"] .sync-chip__dot,
.sync-chip[data-state="error"] .sync-chip__dot,
.sync-chip[data-state="unauthorized"] .sync-chip__dot {
  background: var(--red);
}

.sync-chip[data-state="idle"] {
  border-color: var(--stroke);
  background: var(--chip);
}

.sync-chip[data-state="idle"] .sync-chip__dot {
  background: var(--txt3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.round-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--chip);
  box-shadow: inset 0 1px 0 var(--spec);
  color: var(--txt);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
}

.round-button--ghost {
  background: transparent;
  box-shadow: none;
  color: var(--txt2);
}

.round-button--sm {
  width: 30px;
  height: 30px;
}

.round-button svg {
  width: 15px;
  height: 15px;
}

.round-button.is-active {
  background: var(--on-bg);
  border-color: transparent;
  color: var(--on-fg);
}

.theme-dot {
  width: 12px;
  height: 12px;
  border-radius: 8px;
  background: var(--txt);
  opacity: 0.8;
}

:root[data-theme="dark"] .theme-dot,
:root:not([data-theme="light"]) .theme-dot {
  box-shadow: inset -3px -2px 0 0 var(--chip);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-dot {
    box-shadow: none;
  }
}

:root[data-theme="light"] .theme-dot {
  box-shadow: none;
}

/* 월 이동 */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 13px;
}

.month-nav button {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--txt3);
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
}

.month-nav button:hover {
  background: var(--chip);
  color: var(--txt);
}

.month-nav label {
  position: relative;
  flex: none;
  overflow: hidden;
}

.month-nav input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  height: 100%;
  opacity: 0;
  font-size: 16px; /* iOS 포커스 시 자동 줌 방지 */
}

.month-label {
  display: inline-block;
  min-width: 96px;
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

/* 월 요약 3칸 */
.month-figures {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.month-figures div {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--card);
}

.month-figures div[hidden] {
  display: none;
}

.month-figures span {
  display: block;
  color: var(--txt3);
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1;
}

.month-figures strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.income {
  color: var(--income);
}

.expense {
  color: var(--expense-ink);
}

.transfer {
  color: var(--transfer);
}

.saving {
  color: var(--saving);
}

.negative {
  color: var(--red);
}

/* 장부 메뉴 (L3) */
.ledger-menu {
  position: relative;
}

.ledger-menu__popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 1px;
  width: 196px;
  padding: 6px;
  border-radius: 22px;
  animation: v2-pop 0.18s ease;
}

.ledger-menu__popover[hidden] {
  display: none;
}

.ledger-menu__popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.ledger-menu__popover button[aria-checked="true"] {
  background: var(--chip);
}

.ledger-menu__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: var(--ledger-all);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.ledger-menu__icon[data-ledger-badge="husband"] {
  background: var(--ledger-husband);
}

.ledger-menu__icon[data-ledger-badge="wife"] {
  background: var(--ledger-wife);
}

.ledger-menu__icon[data-ledger-badge="shared"] {
  background: var(--ledger-shared);
}

.ledger-menu__label {
  flex: 1;
  min-width: 0;
}

.ledger-menu__check {
  color: var(--income);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
}

.ledger-menu__popover button[aria-checked="true"] .ledger-menu__check {
  opacity: 1;
}

/* ===== 툴바 ===== */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.controls-bar__spacer {
  flex: 1;
}

.segment {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--card);
}

.segment button {
  padding: 7px 14px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--txt3);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  transition: background 0.25s ease;
}

.segment button.is-active {
  background: var(--on-bg);
  color: var(--on-fg);
}

.segment--fill {
  border-radius: 17px;
}

.segment--fill button {
  flex: 1;
  padding: 9px 0;
  border-radius: 14px;
  text-align: center;
}

.type-chips {
  display: flex;
  gap: 5px;
}

.chip {
  padding: 7px 11px;
  border: 1px solid var(--stroke);
  border-radius: 13px;
  background: transparent;
  color: var(--txt3);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
}

.chip.is-active {
  border-color: transparent;
  background: var(--on-bg);
  color: var(--on-fg);
}

.filter-wrap {
  position: relative;
}

.filter-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  display: grid;
  gap: 10px;
  width: 220px;
  padding: 14px;
  border-radius: 22px;
  animation: v2-pop 0.18s ease;
}

.filter-popover[hidden] {
  display: none;
}

.filter-popover label {
  display: grid;
  gap: 6px;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 500;
}

.filter-popover label[hidden] {
  display: none;
}

.filter-popover select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--stroke);
  border-radius: 13px;
  background: var(--card);
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  appearance: none;
}

.search-bar[hidden] {
  display: none;
}

.history-search input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--card);
  color: var(--txt);
  font-size: 13px;
  appearance: none;
}

.history-search input::placeholder {
  color: var(--txt3);
}

.view-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.view-panel.is-active {
  display: flex;
}

/* ===== 거래 목록 ===== */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.day-group__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 8px 0;
}

.day-group__heading span {
  color: var(--txt2);
  font-size: 12.5px;
  font-weight: 600;
}

.day-group__heading strong {
  color: var(--txt3);
  font-size: 11.5px;
  font-weight: 500;
}

.day-group__card {
  display: flex;
  flex-direction: column;
  padding: 5px;
  border-radius: 24px;
}

.transaction-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 20px;
  background: transparent;
  transition: background 0.15s ease;
}

.transaction-item[role="button"] {
  cursor: pointer;
}

.transaction-item[role="button"]:hover {
  background: var(--chip);
}

.transaction-item__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--ledger-all);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
}

.transaction-item__body {
  flex: 1;
  min-width: 0;
}

.transaction-item h3 {
  margin: 0;
  overflow: hidden;
  color: var(--txt);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-item p {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-item__amount {
  flex: none;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.transaction-item__amount.expense {
  color: var(--expense-ink);
}

.empty-state,
.dashboard-empty {
  margin: 0;
  padding: 26px 16px;
  border-radius: 22px;
  background: var(--card);
  color: var(--txt3);
  font-size: 12.5px;
  text-align: center;
}

/* ===== 달력 ===== */
.calendar-card {
  padding: 14px 12px 16px;
  border-radius: 26px;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 8px;
}

.calendar-weekdays span {
  color: var(--txt2);
  font-size: 10.5px;
  font-weight: 500;
  text-align: center;
}

.calendar-weekdays .is-sun {
  color: var(--red);
}

.calendar-weekdays .is-sat {
  color: var(--blue);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 46px;
  padding: 5px 4px;
  border: 1px solid transparent;
  border-radius: 11px;
  opacity: 0.28;
}

.calendar-day.is-current {
  opacity: 1;
}

.calendar-day.has-activity {
  background: var(--card);
}

.calendar-day.is-today {
  border-color: var(--income);
}

.calendar-day strong {
  color: var(--txt2);
  font-size: 11px;
  font-weight: 600;
}

.calendar-day.is-sun strong {
  color: var(--red);
}

.calendar-day.is-sat strong {
  color: var(--blue);
}

.calendar-day small {
  font-size: 8.5px;
  font-weight: 500;
  line-height: 1.15;
  text-align: center;
}

.calendar-day .day-net.is-plus {
  color: var(--income);
}

.calendar-day .day-net.is-minus {
  color: var(--expense-ink);
}

.calendar-day .day-net.is-zero {
  color: var(--txt3);
}

/* ===== 대시보드 ===== */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dash-head {
  padding: 0 4px;
}

.dash-head--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.dash-eyebrow {
  margin: 0;
  color: var(--txt3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.dash-head h2 {
  margin: 6px 0 0;
  color: var(--txt);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.dash-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.dash-cards div {
  padding: 14px 15px;
  border-radius: 22px;
}

.dash-cards span {
  display: block;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
}

.dash-cards strong {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: var(--txt);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  text-overflow: ellipsis;
}

.dash-section {
  padding: 18px 16px 14px;
  border-radius: 26px;
}

.dash-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.dash-title {
  margin: 0;
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--income);
  font-size: 13px;
  font-weight: 500;
}

.text-button--muted {
  display: block;
  margin: 10px 2px 0;
  color: var(--txt3);
  font-size: 12px;
}

/* 자산 탭 '+매수' 버튼: 기본 .text-button(13px) 대비 약 15% 확대 */
#addAsset {
  padding: 6px 2px;
  font-size: 15px;
}

/* 추이 차트 */
.chart-legend {
  display: flex;
  gap: 9px;
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
}

.legend-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 6px;
  background: var(--txt3);
}

.legend-dot--income {
  background: var(--income);
}

.legend-dot--expense {
  background: var(--expense-bar);
}

.legend-dot--saving {
  background: var(--saving);
}

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 132px;
  margin-top: 18px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--stroke);
}

.trend-month {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  height: 100%;
}

.trend-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2.5px;
  width: 100%;
  height: 100%;
}

.trend-bars i {
  display: block;
  width: 9px;
  border-radius: 3px;
  transition: height 0.4s ease;
}

.trend-bars .is-income {
  background: var(--income);
}

.trend-bars .is-expense {
  background: var(--expense-bar);
}

.trend-bars .is-saving {
  background: var(--saving);
}

.trend-month span {
  color: var(--txt3);
  font-size: 10px;
  font-weight: 500;
}

.trend-month.is-current span {
  color: var(--ink);
}

.trend-caption {
  margin: 10px 0 0;
  color: var(--txt3);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
}

/* 도넛 */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 16px;
}

.donut {
  position: relative;
  flex: none;
  width: 168px;
  height: 168px;
  border-radius: 999px;
}

.donut::after {
  content: "";
  position: absolute;
  top: 25px;
  left: 25px;
  width: 118px;
  height: 118px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--donut-hole);
}

.donut__center {
  position: absolute;
  top: 25px;
  left: 25px;
  z-index: 1;
  display: flex;
  width: 118px;
  height: 118px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.donut__center span {
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
}

.donut__center strong {
  color: var(--txt);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.donut-legend {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.donut-legend .legend-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 7px;
}

.donut-legend .cat-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--txt2);
  font-size: 11.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend em {
  flex: none;
  color: var(--txt3);
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
}

/* 예산 */
.budget-hint {
  margin: 7px 0 0;
  color: var(--txt3);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.4;
}

.budget-hint.is-over {
  color: var(--red);
}

.budget-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 15px;
  padding-bottom: 4px;
}

.budget-item {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.budget-item__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.budget-item__name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  color: var(--txt2);
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-item__icon {
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
}

.budget-item__top strong {
  flex: none;
  color: var(--txt3);
  font-size: 11.5px;
  font-weight: 500;
}

.budget-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--track);
}

.budget-bar span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--income);
  transition: width 0.6s ease;
}

.budget-item__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
}

.budget-item__bottom label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--txt3);
  font-size: 10.5px;
}

.budget-limit-input {
  width: 88px;
  padding: 5px 8px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: var(--card);
  color: var(--txt2);
  font-size: 11px;
  font-weight: 500;
  text-align: right;
  appearance: textfield;
}

.budget-limit-input::-webkit-outer-spin-button,
.budget-limit-input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

/* 고정비 */
.recurring-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.recurring-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px;
  border-radius: 16px;
  cursor: pointer;
}

.recurring-item:hover {
  background: var(--chip);
}

.recurring-item__day {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--stroke);
  border-radius: 13px;
  background: var(--card);
}

.recurring-item__day strong {
  color: var(--txt);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.recurring-item__day span {
  color: var(--txt3);
  font-size: 8px;
  font-weight: 400;
  line-height: 1;
}

.recurring-item__body {
  flex: 1;
  min-width: 0;
}

.recurring-item__body h4 {
  margin: 0;
  overflow: hidden;
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recurring-item__body p {
  margin: 0;
  overflow: hidden;
  color: var(--txt3);
  font-size: 10.5px;
  font-weight: 400;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recurring-item__amount {
  flex: none;
  font-size: 13px;
  font-weight: 600;
}

.recurring-item__amount.expense {
  color: var(--expense-ink);
}

/* 데이터 백업 */
.data-panel__note {
  margin: 8px 0 0;
  color: var(--txt3);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.55;
  text-wrap: pretty;
}

.data-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.button {
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 15px;
  background: var(--chip);
  color: var(--txt2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.button--primary {
  background: linear-gradient(135deg, var(--income-top), var(--income));
  box-shadow: 0 6px 18px rgba(66, 201, 154, 0.32);
  color: var(--on-accent);
  font-weight: 600;
}

.button--ghost {
  border-color: var(--stroke);
  background: var(--chip);
}

.button--danger {
  background: rgba(255, 119, 124, 0.16);
  color: var(--red);
}

.data-panel__import {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

/* ===== 자산 ===== */
.asset-price-status {
  margin: 0;
  padding: 0 4px;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
}

.asset-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.asset-group:not(:empty) + .asset-group:not(:empty) {
  margin-top: 12px;
}

.asset-group__title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 4px 6px 0;
  color: var(--txt2);
  font-size: 12.5px;
  font-weight: 600;
}

.asset-group__badge {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--ledger-all);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

.holding-item {
  padding: 15px 16px;
  border-radius: 24px;
}

.holding-item__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.holding-item__body {
  min-width: 0;
}

.holding-item__body h4 {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  color: var(--txt);
  font-size: 15px;
  font-weight: 600;
}

.holding-item__body h4 small {
  color: var(--txt3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
}

.holding-item__sub {
  margin: 7px 0 0;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
}

.holding-item__profit {
  flex: none;
  text-align: right;
}

.holding-item__profit strong {
  display: block;
  color: var(--income);
  font-size: 15px;
  font-weight: 600;
}

.holding-item__profit span {
  display: block;
  margin-top: 5px;
  color: var(--income);
  font-size: 13px;
  font-weight: 500;
}

.holding-item__profit.negative strong,
.holding-item__profit.negative span {
  color: var(--red);
}

.holding-item__profit.is-muted strong,
.holding-item__profit.is-muted span {
  color: var(--txt3);
}

.lot-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 12px 0 0;
  padding: 11px 0 0;
  border-top: 1px solid var(--stroke);
  list-style: none;
}

.lot-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 3px 4px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
}

.lot-item:hover {
  background: var(--chip);
}

.lot-item span:last-child {
  color: var(--txt2);
}

/* ===== 탭바 + FAB (L2) ===== */
.tabbar-wrap {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 22px);
}

.bottom-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px;
  border-radius: 28px;
}

.bottom-nav button {
  flex: 1;
  padding: 11px 0 10px;
  border: 0;
  border-radius: 21px;
  background: transparent;
  color: var(--txt3);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.25s ease;
}

.bottom-nav .is-current {
  background: var(--chip);
  color: var(--ink);
}

.floating-add {
  position: absolute;
  top: -64px;
  right: 22px;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  padding: 0 0 3px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--income-top), var(--income));
  box-shadow: 0 12px 30px rgba(66, 201, 154, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: var(--on-accent);
  font-size: 27px;
  font-weight: 300;
  line-height: 1;
}

.floating-add[hidden] {
  display: none;
}

/* ===== 시트 (L3) ===== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sheet-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sheet-overlay__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(12, 15, 20, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.sheet {
  position: relative;
  z-index: 1;
  width: min(402px, 100%);
  max-height: 96%;
  margin: 0 auto 8px;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 36px;
  color: var(--txt);
  scrollbar-width: none;
}

.sheet-overlay.is-open .sheet {
  animation: v2-sheet 0.28s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.sheet::-webkit-scrollbar {
  display: none;
}

.sheet__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 22px;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet__title {
  margin: 0;
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
}

.sheet__action {
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--txt3);
  font-size: 14px;
  font-weight: 500;
}

.sheet__action--accent {
  color: var(--income);
  font-weight: 600;
}

.sheet__action--spacer {
  color: transparent;
  pointer-events: none;
}

.sheet__overline {
  margin: 6px 0 -4px;
  color: var(--txt3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sheet__note {
  margin: 0;
  color: var(--txt3);
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.55;
  text-wrap: pretty;
}

.sheet__submit {
  height: 52px;
  border: 0;
  border-radius: 19px;
  background: linear-gradient(135deg, var(--income-top), var(--income));
  box-shadow: 0 10px 26px rgba(66, 201, 154, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 600;
}

.sheet__delete {
  height: 44px;
  border: 1px solid rgba(255, 119, 124, 0.34);
  border-radius: 17px;
  background: rgba(255, 119, 124, 0.14);
  color: var(--red);
  font-size: 13.5px;
  font-weight: 500;
}

.sheet__delete[hidden] {
  display: none;
}

.sheet__button-row {
  display: flex;
  gap: 8px;
}

.sheet__button-row .button {
  flex: 1;
  height: 46px;
  border-radius: 17px;
  font-size: 13.5px;
}

/* 금액 표시 */
.amount-display {
  margin-top: 4px;
  text-align: center;
}

.amount-display__caption {
  margin: 0;
  color: var(--txt3);
  font-size: 12px;
  font-weight: 400;
}

.amount-display__row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  margin: 10px 0 0;
}

.amount-display__value {
  color: var(--ink);
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.amount-display__value.is-empty {
  color: var(--txt3);
  opacity: 0.5;
}

.amount-display__unit {
  color: var(--txt2);
  font-size: 19px;
  font-weight: 600;
}

.amount-display__caret {
  width: 2px;
  height: 30px;
  border-radius: 2px;
  background: var(--income);
  animation: v2-blink 1.1s steps(1, end) infinite;
}

.amount-display__row--sm .amount-display__value {
  font-size: 34px;
}

.amount-display__row--sm .amount-display__unit {
  font-size: 18px;
}

.quick-chips {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
}

.quick-chips button {
  padding: 8px 12px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--chip);
  color: var(--txt2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

/* 장부 선택 */
.pick-row {
  display: flex;
  gap: 5px;
}

.pick-row button {
  flex: 1;
  padding: 11px 0;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--chip);
  color: var(--txt3);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
}

.pick-row button.is-active {
  border-color: transparent;
  background: var(--on-bg);
  color: var(--on-fg);
}

.pick-block[hidden] {
  display: none;
}

.pick-block__label {
  margin: 0 0 6px 2px;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 500;
}

/* 카테고리 칩 */
.chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-wrap[hidden] {
  display: none;
}

.chip-wrap button {
  padding: 8px 12px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: transparent;
  color: var(--txt2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.chip-wrap button.is-active {
  border-color: transparent;
  background: var(--on-bg);
  color: var(--on-fg);
}

.chip-wrap--stocks button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
}

.chip-wrap--stocks small {
  font-family: var(--font-mono);
  font-size: 10.5px;
  opacity: 0.6;
}

/* 필드 그룹 */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  border-radius: 18px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border: 0;
  background: var(--card);
  text-align: left;
}

.field-row > span {
  flex: none;
  color: var(--txt3);
  font-size: 13px;
  font-weight: 400;
}

.field-row input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  text-align: right;
  appearance: none;
}

/* 동기화 입력란을 감싸는 슬롯(설정 시트를 열 때 JS로 채워짐).
   이 자체를 flex 컨테이너로 만들어, 안에 들어갈 input이 기존 .field-row input의
   flex:1 규칙을 그대로 받아 나머지 폭을 채우게 한다. */
.field-slot {
  display: flex;
  flex: 1;
  min-width: 0;
}

.field-row input::placeholder {
  color: var(--txt3);
  opacity: 0.75;
}

.field-row input[type="number"] {
  appearance: textfield;
}

.field-row input[type="number"]::-webkit-outer-spin-button,
.field-row input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.field-row input[type="datetime-local"],
.field-row input[type="date"] {
  text-align: right;
}

/* 공유 토큰: type="password" 대신 CSS로만 가린다(암호 관리자의 로그인 폼 인식 방지) */
.token-masked {
  -webkit-text-security: disc;
  text-security: disc;
}

.field-row--static strong {
  color: var(--txt2);
  font-size: 13px;
  font-weight: 500;
  text-align: right;
}

.sync-status[data-state="ok"] {
  color: var(--income);
}

.sync-status[data-state="offline"],
.sync-status[data-state="error"],
.sync-status[data-state="unauthorized"] {
  color: var(--red);
}

/* 결제일 그리드 */
.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.day-grid button {
  height: 34px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--card);
  color: var(--txt2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.day-grid button.is-active {
  border-color: transparent;
  background: var(--on-bg);
  color: var(--on-fg);
}

/* 키패드 */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.keypad button {
  height: 52px;
  border: 1px solid var(--stroke);
  border-radius: 17px;
  background: var(--key);
  color: var(--txt);
  font-size: 20px;
  font-weight: 500;
}

.keypad button:active {
  background: var(--chip);
}

/* 스테퍼 */
.stepper-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px 11px 14px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: var(--card);
}

.stepper__label {
  color: var(--txt3);
  font-size: 13px;
  font-weight: 400;
}

.stepper__control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stepper__control button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--chip);
  color: var(--txt2);
  font-size: 17px;
  font-weight: 400;
  line-height: 1;
}

.stepper__value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  min-width: 88px;
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
}

.stepper__value input {
  width: 100%;
  min-width: 0;
  max-width: 76px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--txt);
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  appearance: textfield;
}

.stepper__value input::-webkit-outer-spin-button,
.stepper__value input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.stepper__value input::placeholder {
  color: var(--txt3);
}

.stepper__value small {
  flex: none;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 500;
}

/* 토글 행 */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  background: var(--card);
  text-align: left;
}

.toggle-row__text {
  min-width: 0;
}

.toggle-row__label {
  display: block;
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}

.toggle-row__desc {
  display: block;
  margin-top: 3px;
  color: var(--txt3);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
}

.toggle {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--chip);
  transition: background 0.22s ease;
}

.toggle i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(9, 12, 19, 0.3);
  transition: left 0.22s cubic-bezier(0.2, 0.9, 0.25, 1);
}

.toggle-row[aria-pressed="true"] .toggle {
  border-color: transparent;
  background: var(--income);
}

.toggle-row[aria-pressed="true"] .toggle i {
  left: 20px;
}

/* 카테고리 편집기 */
.category-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-name {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--card);
  color: var(--txt);
  font-size: 12.5px;
  font-weight: 500;
}

.category-move,
.category-del {
  display: grid;
  flex: none;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--chip);
  color: var(--txt2);
  font-size: 13px;
  line-height: 1;
}

.category-del {
  border-color: rgba(255, 119, 124, 0.3);
  background: rgba(255, 119, 124, 0.12);
  color: var(--red);
}

.category-move:disabled {
  opacity: 0.35;
  cursor: default;
}

.category-add {
  display: flex;
  gap: 6px;
}

.category-add input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--card);
  color: var(--txt);
  font-size: 12.5px;
}

.category-add input::placeholder {
  color: var(--txt3);
}

.category-txn-list {
  margin-top: 4px;
}

/* ===== 토스트 ===== */
/* 가운데 정렬은 margin auto로 한다 — v2-toast가 transform을 덮어쓰기 때문에 translateX는 못 쓴다 */
.toast {
  position: fixed;
  right: 0;
  bottom: 120px;
  left: 0;
  z-index: 70;
  width: fit-content;
  max-width: min(340px, calc(100% - 48px));
  margin-inline: auto;
  padding: 11px 18px;
  border-radius: 22px;
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  pointer-events: none;
  animation: v2-toast 2.2s ease forwards;
}

.toast[hidden] {
  display: none;
}

/* ===== 모션 축소 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .toast {
    animation: none;
    opacity: 1;
  }
}

/* ==========================================================================
   반응형
   ========================================================================== */

/* 태블릿 이하 — 폰 프레임 해제, 화면 가득 */
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    justify-content: stretch;
    width: 100%;
    padding: 0;
  }

  .phone {
    width: 100%;
    height: 100dvh;
    min-height: 480px;
    border-radius: 0;
    box-shadow: none;
  }

  .sheet {
    margin-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }
}

/* 중형(태블릿) — 요소를 조금 키워 읽기 편하게 */
@media (min-width: 700px) and (max-width: 1180px) {
  .app-header,
  .page-scroll,
  .tabbar-wrap {
    padding-right: 24px;
    padding-left: 24px;
  }

  .app-title {
    font-size: 19px;
  }

  .month-label {
    font-size: 16px;
  }

  .month-figures strong {
    font-size: 16px;
  }

  .transaction-item h3 {
    font-size: 15px;
  }

  .transaction-item p {
    font-size: 12px;
  }

  .transaction-item__amount {
    font-size: 15px;
  }

  .bottom-nav button {
    font-size: 15px;
  }

  .calendar-day {
    min-height: 62px;
  }
}

/* 소형 폰 */
@media (max-width: 380px) {
  .app-header,
  .page-scroll,
  .tabbar-wrap {
    padding-right: 12px;
    padding-left: 12px;
  }

  .type-chips {
    display: none;
  }

  .donut {
    width: 140px;
    height: 140px;
  }

  .donut::after,
  .donut__center {
    top: 21px;
    left: 21px;
    width: 98px;
    height: 98px;
  }
}

/* ===== 데스크탑(1180px 초과): 좌측 사이드바 + 넓은 본문 ===== */
@media (min-width: 1181px) {
  .workspace {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }

  .phone {
    /* 폰 목업 해제. absolute인 .tabbar-wrap은 부모 padding의 영향을 받지 않으므로
       padding-left로 본문(헤더·페이지)만 사이드바 폭만큼 밀린다. */
    width: 100%;
    max-width: none;
    height: 100dvh;
    padding-left: 220px;
    border-radius: 0;
    box-shadow: none;
  }

  /* 하단 바 → 좌측 사이드바 */
  .tabbar-wrap {
    top: 0;
    right: auto;
    bottom: 0;
    left: 0;
    width: 220px;
    padding: 24px 14px;
  }

  .bottom-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px;
    border-radius: 26px;
  }

  .bottom-nav button {
    flex: none;
    padding: 13px 16px;
    font-size: 14px;
    text-align: left;
  }

  .floating-add {
    position: fixed;
    top: auto;
    right: 32px;
    bottom: 32px;
  }

  .app-header,
  #ledgerPage {
    width: 100%;
    max-width: 880px;
    margin-right: auto;
    margin-left: auto;
  }

  .app-header {
    padding-top: 24px;
  }

  /* 종합 정리·자산은 본문이 2열이라 헤더도 같은 폭으로 맞춘다 */
  body[data-page="dashboard"] .app-header,
  body[data-page="assets"] .app-header {
    max-width: 1180px;
  }

  /* 종합 정리·자산: 카드 2열 그리드 */
  .dashboard {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 24px;
    align-items: start;
    align-content: start;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
  }

  .dash-head,
  .dash-cards {
    grid-column: 1 / -1;
  }

  .dash-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .asset-group {
    grid-column: 1 / -1;
  }

  .asset-price-status {
    grid-column: 1 / -1;
  }

  .sheet {
    margin-bottom: 24px;
  }
}
