/* ============================================================
   경조사 장부 — 스타일
   레이아웃: 모바일 우선, 중앙 정렬 단일 컬럼 (최대 560px)
   ============================================================ */

/* --- 디자인 토큰 --- */
:root {
  /* 색 (라이트) — 차콜 · 웜그레이 · 브론즈 (흰 배경) */
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --ink: #221f1b;
  --muted: #8a857c;
  --line: #e7e2d9;

  --brand: #2c2823;        /* 기본 강조 (탭·버튼·FAB) — 차콜 */
  --on-brand: #ffffff;     /* brand 위 글자색 */
  --brand-ink: #2c2823;
  --brand-soft: #ece8e1;
  --accent: #9a7340;       /* 브론즈 포인트 (추천·고급 강조) */

  --recv: #3f6f8f;         /* 받음 */
  --recv-bg: #eaf0f5;
  --give: #a86a42;         /* 냄 */
  --give-bg: #f4ece2;
  --warn: #916a2a;         /* 챙겨야 할 / 임박 (골드브론즈) */
  --warn-bg: #f3ebd7;

  --shadow: 0 1px 2px rgba(34, 31, 27, .04), 0 8px 24px rgba(34, 31, 27, .07);
  --radius: 16px;
  --radius-sm: 10px;

  --font: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1816;
    --surface: #232019;
    --surface-2: #2a2620;
    --ink: #efe9df;
    --muted: #a49d90;
    --line: #39332b;

    --brand: #c9a46a;
    --on-brand: #221f1b;
    --brand-ink: #d8b47a;
    --brand-soft: #2e2920;
    --accent: #c9a46a;

    --recv: #78a7c8;
    --recv-bg: #1c2b36;
    --give: #d08a5a;
    --give-bg: #33241a;
    --warn: #d4a84f;
    --warn-bg: #2f2714;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .42);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1816;
  --surface: #232019;
  --surface-2: #2a2620;
  --ink: #efe9df;
  --muted: #a49d90;
  --line: #39332b;

  --brand: #c9a46a;
  --on-brand: #221f1b;
  --brand-ink: #d8b47a;
  --brand-soft: #2e2920;
  --accent: #c9a46a;

  --recv: #78a7c8;
  --recv-bg: #1c2b36;
  --give: #d08a5a;
  --give-bg: #33241a;
  --warn: #d4a84f;
  --warn-bg: #2f2714;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .42);
  color-scheme: dark;
}

/* --- 리셋 --- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 96px; /* FAB 공간 */
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, button { font-family: inherit; font-size: 1rem; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }

/* --- 레이아웃 뼈대 --- */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* --- 상단 바 --- */
.topbar {
  display: flex;
  align-items: center;
  padding-block: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: var(--shadow);
  display: block;
}
.brand-text h1 { font-size: 19px; font-weight: 900; letter-spacing: -.02em; }
.brand-text p { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

/* 계정 버튼 */
.account-btn {
  margin-left: auto;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 13px;
  box-shadow: var(--shadow);
}
.account-btn.signed { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.account-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 상단 우측 액션 (설정 + 계정) */
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-actions .account-btn { margin-left: 0; }
.top-icon {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  width: 38px; height: 38px; border-radius: 999px; font-size: 17px; line-height: 1;
  box-shadow: var(--shadow); display: grid; place-items: center; padding: 0;
}
.top-icon:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --- 탭 --- */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  padding: 9px 0;
  border-radius: 9px;
  transition: background .15s, color .15s;
}
.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

main { padding-top: 16px; }
.view { display: flex; flex-direction: column; gap: 14px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* --- 예시 배너 --- */
.sample-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: var(--warn-bg);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.sample-banner strong { color: var(--warn); }
.btn-text {
  border: 0; background: transparent; color: var(--warn);
  font-weight: 700; font-size: 13px; padding: 4px 2px; white-space: nowrap;
  text-decoration: underline; text-underline-offset: 2px;
}

/* --- 연도 선택 --- */
.year-row { display: flex; align-items: center; gap: 10px; }
.year-row label { font-size: 13px; color: var(--muted); font-weight: 500; }
#yearSelect {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 7px 10px; font-weight: 700;
}

/* --- 통계 카드 --- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow);
}
.stat.wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 22px; font-weight: 900; margin-top: 4px; letter-spacing: -.02em; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.recv { background: var(--recv); }
.dot.give { background: var(--give); }
.v.recv { color: var(--recv); }
.v.give { color: var(--give); }
.net-badge { font-size: 13px; font-weight: 800; padding: 6px 12px; border-radius: 999px; }
.net-badge.plus { background: var(--recv-bg); color: var(--recv); }
.net-badge.minus { background: var(--give-bg); color: var(--give); }
.net-badge.zero { background: var(--surface-2); color: var(--muted); }

/* --- 통계 대시보드 --- */
.dashboard { display: flex; flex-direction: column; gap: 10px; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px 13px;
  box-shadow: var(--shadow);
}
.chart-title { font-size: 13px; font-weight: 800; color: var(--ink); margin-bottom: 12px; letter-spacing: -.01em; }

/* 기간별 추이 (받음/냄 그룹 막대) */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 104px; padding: 0 2px; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bar {
  width: 7px; max-width: 46%;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height .25s ease;
}
.bar.recv { background: var(--recv); }
.bar.give { background: var(--give); }
.bar.zero { min-height: 0; background: transparent; }
.bar-label { font-size: 10.5px; color: var(--muted); margin-top: 6px; font-weight: 600; white-space: nowrap; }
.bar-label.has { color: var(--ink); }
.chart-legend { display: flex; gap: 16px; margin-top: 12px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: 1px; }
.chart-legend i.recv { background: var(--recv); }
.chart-legend i.give { background: var(--give); }

/* 분포 (관계별 / 종류별 가로 막대) */
.dist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.dist-row { display: flex; align-items: center; gap: 10px; }
.dist-label { flex: none; width: 66px; font-size: 12.5px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dist-track { flex: 1; min-width: 0; height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.dist-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.dist-val { flex: none; width: 92px; text-align: right; font-size: 12.5px; font-weight: 800; color: var(--ink); }
.dist-val small { font-weight: 600; color: var(--muted); font-size: 11px; margin-left: 5px; }

/* --- 섹션 헤더 --- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; }
.section-head h2 { font-size: 16px; font-weight: 900; letter-spacing: -.02em; }
.section-head .hint { font-size: 12px; color: var(--muted); }

/* --- 사람 리스트 (요약 '챙길 사람' + 사람별 공용) --- */
.person-list { display: flex; flex-direction: column; gap: 9px; }
.person-card {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
  transition: transform .08s;
}
.person-card:active { transform: scale(.99); }
.person-card.todo { border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
  background: var(--brand-soft); color: var(--brand-ink);
}
.person-main { flex: 1; min-width: 0; }
.person-name { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 7px; }
.person-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.tag {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.person-amt { text-align: right; flex: none; }
.person-amt .big { font-weight: 900; font-size: 15px; letter-spacing: -.01em; }
.person-amt .big.warn { color: var(--warn); }
.person-amt .small { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* 사람별 편집형 카드: [관계 ▼] [이름·받음·냄] [차액] + 메모 */
.person-card--edit { flex-direction: column; align-items: stretch; gap: 10px; }
.person-card--edit:active { transform: none; }
.person-row { display: flex; align-items: center; gap: 11px; }
.relation-select {
  flex: none; width: 90px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--brand-ink);
  border-radius: 10px; padding: 9px 8px; font-weight: 700; font-size: 13px;
}
.relation-select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.person-card--edit .person-main {
  flex: 1; min-width: 0; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.person-card--edit .person-name { font-weight: 800; font-size: 15px; }
.person-side { flex: none; text-align: right; }
.person-side .big { font-weight: 900; font-size: 15px; letter-spacing: -.01em; }
.person-side .big.warn { color: var(--warn); }
.person-side .small { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.person-memo {
  width: 100%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 9px 12px; font-size: 13px;
}
.person-memo::placeholder { color: var(--muted); }
.person-memo:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

/* 요약 '챙겨야 할 사람'의 관계 표시(읽기 전용, 이름 정렬용 고정폭) */
.relation-static {
  flex: none; width: 72px; text-align: center;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--brand-ink);
  border-radius: 10px; padding: 8px 6px; font-weight: 700; font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 섹션 헤더의 작은 추가 버튼 */
.btn-add-sm {
  border: 1px solid var(--line); background: var(--surface); color: var(--brand-ink);
  border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 12.5px;
  box-shadow: var(--shadow);
}
.btn-add-sm:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 다가오는 경조사 */
.event-list { display: flex; flex-direction: column; gap: 9px; }
.small-empty { padding: 20px 16px; font-size: 13px; }
.event-card {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 13px; box-shadow: var(--shadow);
}
.event-card.soon { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.dday {
  flex: none; min-width: 48px; text-align: center;
  font-weight: 900; font-size: 13px; color: var(--muted);
  background: var(--surface-2); border-radius: 10px; padding: 9px 6px;
}
.dday.soon { background: var(--warn-bg); color: var(--warn); }
.event-main { flex: 1; min-width: 0; text-align: left; background: transparent; border: 0; padding: 0; }
.event-name { font-weight: 800; font-size: 14.5px; display: flex; align-items: center; gap: 7px; color: var(--ink); }
.event-meta { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-do {
  flex: none; border: 0; background: var(--brand); color: #fff;
  border-radius: 10px; padding: 9px 14px; font-weight: 800; font-size: 13px;
}
.event-main:focus-visible, .event-do:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 체크박스 행 (일정 매년 반복) */
.check-row { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }

/* --- 도구 모음 (검색/필터) --- */
.toolbar { display: flex; gap: 8px; }
.toolbar-filters { gap: 7px; }
.toolbar-filters select {
  flex: 1; min-width: 0;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 9px 8px; font-weight: 600; font-size: 13px;
}
.toolbar-filters select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.search-wrap { flex: 1; min-width: 0; }
#searchInput {
  width: 100%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 13px;
}
#dirFilter {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px; font-weight: 600;
}
#searchInput:focus, #dirFilter:focus, #yearSelect:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* 활성 필터 칩 (특정 사람 보기) */
.active-filter { display: flex; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand-soft); color: var(--brand-ink);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-radius: 999px; padding: 7px 8px 7px 14px;
  font-weight: 700; font-size: 13px;
}
.filter-chip button {
  border: 0; background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: inherit; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; line-height: 1;
}

/* 키보드 포커스 표시 */
.tab:focus-visible,
.person-card:focus-visible,
.record:focus-visible,
.fab:focus-visible,
.icon-btn:focus-visible,
.btn-primary:focus-visible,
.btn-danger:focus-visible,
.btn-text:focus-visible,
.quick-amounts button:focus-visible,
.filter-chip button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 토스트 */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  max-width: min(520px, calc(100vw - 32px));
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  z-index: 60; text-align: center;
  animation: fade .18s ease;
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.toast-action {
  flex: none;
  border: 1px solid color-mix(in srgb, var(--bg) 45%, transparent);
  background: color-mix(in srgb, var(--bg) 16%, transparent);
  color: var(--bg); font-weight: 800; font-size: 13px;
  padding: 6px 13px; border-radius: 999px; white-space: nowrap;
}
.toast-action:focus-visible { outline: 2px solid var(--bg); outline-offset: 2px; }

/* 브랜드 인트로 (One ODD Day) */
.intro {
  position: fixed; inset: 0; z-index: 9999;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  animation: introOut .5s ease 2.6s forwards;
}
.intro-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.intro-char { width: 188px; height: 188px; display: block; }
.intro-wm { width: 230px; max-width: 62vw; height: auto; display: block; }
.intro-skip {
  position: fixed; left: 0; right: 0;
  bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  text-align: center; color: rgba(255, 255, 255, .38); font-size: 12.5px;
}
@keyframes introOut { to { opacity: 0; visibility: hidden; pointer-events: none; } }
@media (prefers-reduced-motion: reduce) { .intro { animation-delay: 1.1s; } }

/* --- 기록 리스트 --- */
.record-list { display: flex; flex-direction: column; gap: 8px; }
.month-label { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 2px 2px; }
.record {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  box-shadow: var(--shadow);
  transition: transform .08s;
}
.record:active { transform: scale(.99); }
.record.received { border-left-color: var(--recv); }
.record.given { border-left-color: var(--give); }
.rec-main { flex: 1; min-width: 0; }
.rec-top { font-weight: 800; font-size: 14.5px; display: flex; align-items: center; gap: 7px; }
.rec-sub { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-amt { font-weight: 900; font-size: 15px; flex: none; letter-spacing: -.01em; }
.rec-amt.received { color: var(--recv); }
.rec-amt.given { color: var(--give); }
.pill { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.pill.received { background: var(--recv-bg); color: var(--recv); }
.pill.given { background: var(--give-bg); color: var(--give); }

/* --- 빈 상태 --- */
.empty {
  text-align: center; color: var(--muted);
  padding: 44px 20px; font-size: 14px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty .big { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }

/* --- FAB --- */
.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 7px;
  background: var(--brand); color: #fff;
  border: 0; border-radius: 999px;
  padding: 14px 20px;
  font-weight: 800; font-size: 15px;
  box-shadow: 0 8px 22px rgba(34, 31, 27, .26);
  z-index: 20;
}
.fab-plus { font-size: 20px; line-height: 1; margin-top: -2px; }

/* --- 모달 --- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(20, 17, 14, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.modal {
  background: var(--surface);
  width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0;
  padding: 18px max(18px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  max-height: 92vh; overflow-y: auto;
  animation: slideup .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; margin: 20px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { font-size: 18px; font-weight: 900; }
.icon-btn { border: 0; background: var(--surface-2); color: var(--muted); width: 32px; height: 32px; border-radius: 9px; font-size: 14px; }

/* --- 폼 --- */
.entry-form { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink); }
.field .optional { color: var(--muted); font-weight: 500; }
.field input, .field select {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 11px 13px; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

/* 관계 선택 칩 */
.chipset { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 9px 15px; font-weight: 700; font-size: 13.5px;
  transition: background .12s, color .12s, border-color .12s;
}
.chip.is-active {
  background: var(--brand); color: var(--on-brand); border-color: var(--brand);
}
.chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.seg {
  display: flex; gap: 6px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 5px;
}
.seg-opt { flex: 1; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: block; text-align: center; padding: 10px 0;
  border-radius: 8px; font-weight: 800; font-size: 14px; color: var(--muted);
  transition: background .12s, color .12s;
}
.seg-opt input[value="received"]:checked + span { background: var(--recv-bg); color: var(--recv); }
.seg-opt input[value="given"]:checked + span { background: var(--give-bg); color: var(--give); }

.amount-wrap { position: relative; }
.amount-wrap input { padding-right: 34px; font-weight: 800; font-size: 17px; }
.amount-wrap .won { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.quick-amounts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.quick-amounts button {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 13px;
}
.quick-amounts button.clear { color: var(--muted); margin-left: auto; }
.suggest { margin-top: 2px; }
.suggest-chip {
  width: 100%; text-align: left;
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--warn-bg); color: var(--accent);
  border-radius: 10px; padding: 10px 13px; font-weight: 800; font-size: 13.5px;
}
.suggest-chip .why { font-weight: 600; color: color-mix(in srgb, var(--accent) 72%, var(--muted)); margin-left: 6px; }
.suggest-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.btn-primary {
  flex: 1; border: 0; background: var(--brand); color: #fff;
  border-radius: 12px; padding: 14px; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow);
}
.btn-danger {
  border: 1px solid color-mix(in srgb, var(--give) 40%, transparent);
  background: transparent; color: var(--give);
  border-radius: 12px; padding: 14px 18px; font-weight: 800; font-size: 15px;
}

/* 로그인/계정 모달 */
.auth-modal { max-width: 460px; }
.auth-desc { font-size: 14px; color: var(--muted); margin-bottom: 14px; line-height: 1.55; }
.auth-desc strong { color: var(--ink); }
.auth-sync { font-size: 12.5px; color: var(--muted); margin: -4px 0 14px; }
.auth-msg { font-size: 13px; margin-top: 12px; padding: 10px 12px; border-radius: 10px; line-height: 1.5; }
.auth-msg.ok { background: var(--brand-soft); color: var(--brand-ink); }
.auth-msg.err { background: var(--give-bg); color: var(--give); }
.btn-secondary {
  width: 100%; margin-bottom: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 12px; padding: 13px; font-weight: 800; font-size: 14.5px;
}
.btn-secondary:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-danger.block { width: 100%; }

/* --- 설정 모달 --- */
.settings-body { display: flex; flex-direction: column; gap: 22px; }
.set-group { display: flex; flex-direction: column; gap: 10px; }
.set-label { font-size: 12.5px; font-weight: 800; color: var(--muted); letter-spacing: .02em; }
.set-hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.seg.seg-3 .seg-opt { flex: 1; }
#themeSeg .seg-opt input:checked + span { background: var(--brand); color: var(--on-brand); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row-k { font-size: 14px; font-weight: 600; color: var(--ink); }
.set-select {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 9px 12px; font-weight: 700; min-width: 132px;
}
.set-select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.set-btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 12px; padding: 13px; font-weight: 800; font-size: 14.5px; width: 100%; text-align: center;
}
.set-btn.danger { color: var(--give); background: transparent; border-color: color-mix(in srgb, var(--give) 40%, transparent); }
.set-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.set-info { font-size: 13.5px; color: var(--ink); font-weight: 600; }
.set-info.sub { font-size: 12px; color: var(--muted); font-weight: 500; }

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