/* ───────────────────────── 토큰 ───────────────────────── */
:root{
  --bg:#f2f2f7; --surface:#ffffff; --surface-2:#f9f9fb;
  --ink:#1c1c1e; --ink-2:#3a3a3c; --muted:#8e8e93; --line:#e5e5ea; --line-2:#efeff4;
  --accent:#448BE9; --accent-soft:#e6f0fc; --save:#c47f0e; --warn:#ff9500; --on-accent:#fff; --danger:#ff3b30; --success:#34c759;
  --shadow:0 1px 2px rgba(0,0,0,.05), 0 8px 24px -16px rgba(0,0,0,.18);
  --radius:14px; --radius-s:10px;
  --tab-h:58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#000000; --surface:#1c1c1e; --surface-2:#2c2c2e;
    --ink:#f2f2f7; --ink-2:#d1d1d6; --muted:#8e8e93; --line:#38383a; --line-2:#2c2c2e;
    --accent:#5c9df0; --accent-soft:#12284a; --save:#f0b44a; --warn:#ff9f0a; --on-accent:#0b1a33; --danger:#ff453a; --success:#30d158;
    --shadow:0 1px 2px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --bg:#000000; --surface:#1c1c1e; --surface-2:#2c2c2e;
  --ink:#f2f2f7; --ink-2:#d1d1d6; --muted:#8e8e93; --line:#38383a; --line-2:#2c2c2e;
  --accent:#5c9df0; --accent-soft:#12284a; --save:#f0b44a; --warn:#ff9f0a; --on-accent:#0b1a33; --danger:#ff453a; --success:#30d158;
  --shadow:0 1px 2px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ───────────────────────── 기본 ───────────────────────── */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Apple SD Gothic Neo","Pretendard","Segoe UI","Noto Sans KR",Roboto,sans-serif;
  font-size:16px; line-height:1.45; -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent; overscroll-behavior-y:none;
}
button,input,select{font:inherit; color:inherit}
button{background:none; border:0; padding:0; cursor:pointer}
h1,h2,h3,p{margin:0}
code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.9em; background:var(--line-2); padding:1px 5px; border-radius:5px}
.hidden{display:none !important}
.muted{color:var(--muted)}
.small{font-size:13px}
.center-text{text-align:center}
.grow{flex:1; min-width:0}
.row{display:flex; gap:8px; align-items:center}
.stack{display:flex; flex-direction:column; gap:10px}

.screen{min-height:100%}
.screen.center{display:flex; align-items:center; justify-content:center; padding:24px 16px}
.spinner{width:28px; height:28px; border:3px solid var(--line); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

.card{background:var(--surface); border-radius:var(--radius); padding:18px; box-shadow:var(--shadow)}
.card.narrow{width:100%; max-width:380px}
.card p+p{margin-top:8px}
.brand{font-size:34px; font-weight:800; letter-spacing:-.03em; margin-bottom:2px}
.brand+.muted{margin-bottom:18px}

.input{
  width:100%; background:var(--surface-2); border:1px solid transparent; border-radius:var(--radius-s);
  padding:11px 13px; outline:none; transition:border-color .15s, background .15s;
}
.input:focus{border-color:var(--accent); background:var(--surface)}
.input::placeholder{color:var(--muted)}
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  background:var(--surface-2); color:var(--accent); font-weight:600;
  border-radius:var(--radius-s); padding:11px 16px; white-space:nowrap;
  transition:transform .08s, opacity .15s;
}
.btn:active{transform:scale(.97)}
.btn:disabled{opacity:.5; cursor:default}
.btn.primary{background:var(--accent); color:var(--on-accent)}
.btn.sm{padding:7px 12px; font-size:14px}
.btn.google{width:100%; background:var(--surface); color:var(--ink); border:1px solid var(--line); padding:13px 16px; font-size:16px; box-shadow:var(--shadow)}
.btn.danger-text{color:var(--danger); width:100%; margin-top:18px}
.icon-btn{width:36px; height:36px; border-radius:50%; font-size:24px; color:var(--accent); display:grid; place-items:center; line-height:1}
.icon-btn:active{background:var(--line-2)}
.msg{margin-top:12px; font-size:14px; color:var(--danger)}
.msg.ok{color:var(--success)}

.seg{display:flex; background:var(--line-2); border-radius:var(--radius-s); padding:3px; margin:14px 0}
.seg-btn{flex:1; padding:7px; border-radius:8px; font-size:14px; font-weight:600; color:var(--muted); transition:all .15s}
.seg-btn.active{background:var(--surface); color:var(--ink); box-shadow:0 1px 3px rgba(0,0,0,.12)}

.emoji-pick{
  width:46px; height:46px; flex:none; border-radius:50%; background:var(--surface-2);
  font-size:24px; display:grid; place-items:center; border:1px solid var(--line);
}
.color-pick{width:34px; height:34px; flex:none; border:0; padding:0; background:none; border-radius:50%; overflow:hidden; cursor:pointer}
.color-pick::-webkit-color-swatch-wrapper{padding:0}
.color-pick::-webkit-color-swatch{border:0; border-radius:50%}

/* ───────────────────────── 메인 레이아웃 ───────────────────────── */
.phone{max-width:640px; margin:0 auto; min-height:100vh; min-height:100dvh; position:relative; background:var(--bg)}
@media (min-width:700px){
  body{background:var(--bg)}
  .phone{border-left:1px solid var(--line); border-right:1px solid var(--line)}
}
.view{padding-bottom:calc(var(--tab-h) + var(--safe-b) + 24px)}
.content{padding:12px 16px}

.topbar{
  position:sticky; top:0; z-index:5; background:var(--bg);
  padding:calc(env(safe-area-inset-top,0px) + 10px) 12px 8px; border-bottom:1px solid var(--line);
}
.topbar-row{display:flex; align-items:center; justify-content:space-between}



/* ───────────────────────── 탭바 ───────────────────────── */
.tabbar{
  position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:640px; z-index:10;
  display:flex; background:color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter:saturate(180%) blur(16px);
  -webkit-backdrop-filter:saturate(180%) blur(16px); border-top:1px solid var(--line);
  padding-bottom:var(--safe-b); height:calc(var(--tab-h) + var(--safe-b));
}
.tab{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; font-size:11px; color:var(--muted); font-weight:500; position:relative}
.tab.active{color:var(--accent)}
.tab-ico{width:24px; height:24px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round}

/* ───────────────────────── 시트 ───────────────────────── */
.sheet{position:fixed; inset:0; z-index:50; display:flex; align-items:flex-end; justify-content:center}
.sheet-backdrop{position:absolute; inset:0; background:rgba(0,0,0,.35); animation:fade .18s}
.sheet-panel{
  position:relative; width:100%; max-width:560px; background:var(--surface); border-radius:18px 18px 0 0;
  padding:8px 16px calc(16px + var(--safe-b)); animation:up .22s cubic-bezier(.2,.8,.2,1); max-height:85vh; overflow:auto;
}
@media (min-width:700px){
  .sheet{align-items:center}
  .sheet-panel{border-radius:18px; padding-bottom:16px}
  .sheet-handle{display:none}
}
.sheet-handle{width:36px; height:5px; border-radius:3px; background:var(--line); margin:4px auto 12px}
.sheet-title{font-weight:700; font-size:17px; margin:6px 2px 12px; word-break:break-word}
.sheet-list{display:flex; flex-direction:column; gap:2px}
.sheet-item{display:flex; align-items:center; gap:12px; padding:13px 10px; border-radius:var(--radius-s); text-align:left; width:100%; font-size:16px}
.sheet-item:active{background:var(--line-2)}
.sheet-item .ico{width:26px; text-align:center; font-size:18px}
.sheet-item.danger{color:var(--danger)}
.sheet-item.cancel{justify-content:center; color:var(--muted); font-weight:600; margin-top:6px}
.emoji-grid{display:grid; grid-template-columns:repeat(8,1fr); gap:6px; margin:8px 0 12px}
.emoji-grid button{font-size:26px; padding:8px 0; border-radius:10px}
.emoji-grid button:active,.emoji-grid button.on{background:var(--accent-soft)}
@keyframes fade{from{opacity:0}}
@keyframes up{from{transform:translateY(30px); opacity:0}}

.toast{
  position:fixed; left:50%; bottom:calc(var(--tab-h) + var(--safe-b) + 16px); transform:translateX(-50%);
  background:var(--ink); color:var(--bg); padding:10px 16px; border-radius:999px; font-size:14px; font-weight:500;
  z-index:60; box-shadow:0 8px 24px rgba(0,0,0,.25); animation:fade .15s; max-width:90vw; text-align:center;
}

/* ───────────────────────── 모아두 ───────────────────────── */
.date-title{font-size:20px; font-weight:700; letter-spacing:-.02em; padding:4px 10px; border-radius:8px}
.date-title:active{background:var(--line-2)}
.section-title{font-size:13px; font-weight:600; color:var(--muted); letter-spacing:.04em; margin:22px 4px 8px}
.list{background:var(--surface); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow)}
.list:empty{display:none}
.empty{text-align:center; color:var(--muted); padding:40px 0 24px}
.empty-emoji{font-size:40px; margin-bottom:8px}
.more{width:32px; height:32px; border-radius:50%; color:var(--muted); font-size:20px; display:grid; place-items:center; flex:none}
.more:active{background:var(--line-2)}
.neg{color:var(--danger) !important}
.hint{margin:8px 4px 0}
.btn.wide{width:100%}
.btn.danger-soft{color:var(--danger)}
.content > .card + .card{margin-top:12px}

/* 진행 막대 */
.bar{position:relative; height:8px; background:var(--line-2); border-radius:4px; margin:12px 0 8px}
.bar i{display:block; height:100%; border-radius:4px; background:var(--accent); transition:width .3s}
.bar.big{height:12px; border-radius:6px}
.bar.big i{border-radius:6px}
.bar.thin{height:5px; margin:6px 0 0}
.bar i.fast{background:var(--warn)}
.bar i.over{background:var(--danger)}
.bar i.save{background:var(--save)}
.today-mark{position:absolute; top:-4px; bottom:-4px; width:2px; background:var(--ink); opacity:.55; border-radius:1px; transform:translateX(-1px)}

/* 홈 카드 */
.hero-label{font-size:14px; color:var(--muted); font-weight:600}
.hero-num{font-size:34px; font-weight:800; letter-spacing:-.03em; margin:2px 0; font-variant-numeric:tabular-nums}
.hero-sub{display:flex; justify-content:space-between; gap:8px; flex-wrap:wrap; font-size:13px; color:var(--muted)}
.hero-sub b{color:var(--ink)}
.hero .btn{margin-top:10px}
.warn{margin-top:8px; font-size:13px; color:var(--warn); font-weight:600}
.goal-head{display:flex; justify-content:space-between; font-weight:700}
.goal-pct{color:var(--save)}
.goal-num{font-size:22px; font-weight:800; letter-spacing:-.02em; margin:4px 0 2px; font-variant-numeric:tabular-nums}
.goal-num .muted{font-size:15px; font-weight:600}
.goal-line{font-size:15px}
.goal-line b{color:var(--save)}
.goal .btn{margin-top:10px}

.triple{display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:12px}
.triple > div{background:var(--surface); border-radius:var(--radius-s); padding:10px 12px; box-shadow:var(--shadow); display:flex; flex-direction:column; min-width:0}
.triple span{font-size:12px; color:var(--muted); font-weight:600}
.triple b{font-size:15px; font-variant-numeric:tabular-nums; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.inc{color:var(--accent)} .sav{color:var(--save)}

.cat-line{display:flex; align-items:center; gap:12px; padding:11px 14px}
.cat-line + .cat-line{border-top:1px solid var(--line-2)}
.cat-emo{width:32px; height:32px; flex:none; border-radius:50%; background:var(--surface-2); display:grid; place-items:center; font-size:17px}
.cat-top{display:flex; justify-content:space-between; gap:8px; font-size:15px; font-variant-numeric:tabular-nums}
.cat-top .muted{font-size:13px}

/* 내역 */
.day-group{margin-bottom:16px}
.day-head{display:flex; justify-content:space-between; font-size:13px; font-weight:600; padding:4px 4px 6px}
.entry{display:flex; align-items:center; gap:12px; padding:10px 14px; width:100%; text-align:left; min-height:52px}
.entry + .entry{border-top:1px solid var(--line-2)}
.entry:active{background:var(--line-2)}
.entry-txt{display:flex; flex-direction:column; min-width:0}
.entry-txt > span:first-child{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.amt{font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap}
.amt.income{color:var(--accent)} .amt.saving{color:var(--save)}

/* 기록 시트 */
.kind-seg{margin:4px 0 10px}
.amount-input{
  width:100%; border:0; outline:none; background:none; text-align:center;
  font-size:40px; font-weight:800; letter-spacing:-.03em; padding:6px 0; font-variant-numeric:tabular-nums;
}
.amount-input::placeholder{color:var(--line)}
.quick{display:flex; gap:6px; justify-content:center; flex-wrap:wrap; margin:4px 0 12px}
.chip{padding:6px 11px; border-radius:999px; background:var(--line-2); font-size:13px; font-weight:600; color:var(--ink-2)}
.chip:active{background:var(--accent-soft)}
.meta-row .date-in{width:150px; flex:none}
.cat-hint{margin:12px 2px 6px}
.cat-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(96px,1fr)); gap:6px}
.cat-chip{display:flex; flex-direction:column; align-items:center; gap:2px; padding:10px 4px; border-radius:var(--radius-s); background:var(--surface-2); font-size:13px; font-weight:600; border:2px solid transparent}
.cat-chip span{font-size:22px}
.cat-chip:active{transform:scale(.97)}
.cat-chip.on{border-color:var(--accent); background:var(--accent-soft)}
.sheet-actions{margin-top:14px}

/* 설정 */
.field{display:flex; flex-direction:column; gap:4px; font-size:13px; color:var(--muted); font-weight:600}
.field .input{color:var(--ink); font-weight:400; font-size:16px}
.cat-row{display:flex; align-items:center; gap:8px; padding:8px 10px}
.cat-row + .cat-row{border-top:1px solid var(--line-2)}
.cat-row .input{padding:9px 11px}
.budget-in{width:118px; flex:none; text-align:right; font-variant-numeric:tabular-nums}
.emoji-pick.sm{width:38px; height:38px; font-size:19px}
.form-cat{margin-top:10px}

/* 기록 버튼 */
.fab{
  position:fixed; z-index:9; right:max(16px, calc(50% - 320px + 16px)); bottom:calc(var(--tab-h) + var(--safe-b) + 16px);
  width:58px; height:58px; border-radius:50%; background:var(--accent); color:var(--on-accent);
  font-size:32px; font-weight:400; line-height:1; display:grid; place-items:center;
  box-shadow:0 8px 24px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}
.fab:active{transform:scale(.95)}
@media (max-width:380px){ .budget-in{width:96px} .meta-row .date-in{width:132px} .hero-num{font-size:30px} }

/* 친구 */
.share-seg{margin:0 0 10px}
.share-seg .seg-btn{font-size:13px; padding:8px 4px}
.friend-card{padding:14px}
.friend-card + .friend-card{border-top:1px solid var(--line-2)}
.fr-head{display:flex; align-items:center; gap:12px; margin-bottom:10px}
.fr-name{font-weight:700}
.fr-line{margin-top:6px; color:var(--ink-2)}
.fr-budget{margin-top:10px}
.cheer-row{display:flex; gap:6px; flex-wrap:wrap; margin-top:12px}
.react{display:inline-flex; align-items:center; gap:4px; font-size:15px; padding:4px 10px; border-radius:999px; background:var(--line-2); border:1px solid transparent}
.react.mine{background:var(--accent-soft); border-color:var(--accent)}
.cheers-got{display:flex; flex-wrap:wrap; gap:6px; padding:12px}
.cheers-got .react{font-size:14px}
.person-row{display:flex; align-items:center; gap:12px; padding:10px 14px}
.person-row + .person-row{border-top:1px solid var(--line-2)}
.person-row .btn + .btn{margin-left:-4px}
.search-list{margin-top:10px}
.fr-head .more{margin-left:auto}

/* 로그인 — 오늘두와 같은 구성 (로고 · 이름 · 한 줄 소개 · Google 버튼) */
.screen.center{min-height:100vh; min-height:100dvh}
.brand{font-size:2.1rem; font-weight:800; letter-spacing:-.03em; display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; margin:0}
.brand-en{font-size:.55em; font-weight:600; color:var(--muted); letter-spacing:.01em}
.auth{width:100%; max-width:340px; display:flex; flex-direction:column; align-items:center; text-align:center; padding:24px 0 40px}
.auth-logo{border-radius:18px; box-shadow:var(--shadow); margin-bottom:22px}
.auth .brand{justify-content:center; margin-bottom:6px}
.tagline{color:var(--ink-2); font-size:1.05rem; margin:0 0 32px}
.auth .btn.google{height:48px}
.auth .msg{margin-top:14px; font-size:.87rem; line-height:1.5}

/* ───────────────────────── PC (마우스 쓰는 기기) ─────────────────────────
   창 폭이 아니라 기기로 가른다: 마우스(hover · fine pointer)면 창을 줄여도 PC 화면 유지.
   폰 · 태블릿(터치)은 하단 탭. 왼쪽 메뉴, 홈 2단, 나머지 화면은 읽기 좋은 폭으로 가운데 */
select.input{appearance:none; -webkit-appearance:none; background-image:linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%); background-position:calc(100% - 18px) 50%,calc(100% - 13px) 50%; background-size:5px 5px; background-repeat:no-repeat; padding-right:34px}
.side-brand{display:none}
@media (hover:hover) and (pointer:fine){
  :root{--side-w:232px}
  .phone{max-width:none; margin:0 0 0 var(--side-w); border:0 !important}
  .topbar{padding-left:32px; padding-right:32px}
  .topbar-row{max-width:1040px; margin:0 auto; justify-content:center; gap:18px}
  .view{padding-bottom:48px}
  .content{max-width:1040px; margin:0 auto; padding:24px 32px}
  #view-friends .content, #view-settings .content{max-width:680px}

  .tabbar{
    left:0; top:0; bottom:0; transform:none; width:var(--side-w); max-width:none; height:auto;
    flex-direction:column; justify-content:flex-start; gap:4px;
    padding:calc(env(safe-area-inset-top,0px) + 22px) 14px 22px;
    border-top:0; border-right:1px solid var(--line); background:var(--surface);
    -webkit-backdrop-filter:none; backdrop-filter:none;
  }
  .side-brand{display:flex; align-items:center; gap:10px; padding:2px 10px 22px; font-weight:800; font-size:19px; letter-spacing:-.02em}
  .side-brand img{border-radius:9px; box-shadow:var(--shadow)}
  .side-brand em{font-style:normal; font-weight:600; font-size:12px; color:var(--muted); margin-left:2px}
  .tab{flex:none; flex-direction:row; justify-content:flex-start; gap:12px; padding:11px 12px; border-radius:var(--radius-s); font-size:15px; font-weight:600}
  .tab:hover{background:var(--line-2)}
  .tab.active{background:var(--accent-soft)}
  .tab-ico{width:22px; height:22px}

  /* 홈: 예산 · 목표 나란히, 나머지는 가로 전체 */
  #home{display:grid; grid-template-columns:1fr 1fr; gap:16px; align-items:start}
  #home > *{grid-column:1 / -1; margin:0 !important}
  #home > .hero, #home > .goal{grid-column:auto; height:100%}
  #home > .section-title{margin:8px 4px -4px !important}
  .hero-num{font-size:40px}

  /* 내역: 날짜 묶음 2단 */
  #list{columns:2; column-gap:16px}
  #list .day-group{break-inside:avoid; display:inline-block; width:100%}

  .fab{right:40px; bottom:40px}
  .toast{left:calc(50% + var(--side-w) / 2); bottom:40px}
}

/* PC 창이 좁아졌을 때: 홈 · 내역 1단 → 더 좁으면 왼쪽 메뉴를 아이콘만 남긴 막대로 */
@media (hover:hover) and (pointer:fine) and (max-width:900px){
  #home{grid-template-columns:1fr}
  #home > .hero, #home > .goal{grid-column:1 / -1}
  #list{columns:1}
}
@media (hover:hover) and (pointer:fine) and (max-width:680px){
  :root{--side-w:68px}
  .tabbar{padding-left:10px; padding-right:10px}
  .side-brand{justify-content:center; padding:2px 0 22px}
  .side-brand span{display:none}
  .tab{font-size:0; justify-content:center; padding:12px 0; gap:0}
  .topbar{padding-left:16px; padding-right:16px}
  .content{padding:16px}
  .fab{right:20px; bottom:20px}
}

/* 사용법 · 업데이트 기록 */
.guide2{display:flex; flex-direction:column; gap:14px}
.g2{display:grid; grid-template-columns:30px 1fr; gap:10px; align-items:start}
.g2-i{width:30px; height:30px; border-radius:9px; background:var(--surface-2); display:grid; place-items:center; font-size:15px}
.g2 b{font-size:15px}
.g2 p{margin:2px 0 0; font-size:14px; line-height:1.55; color:var(--ink-2); word-break:keep-all}
.howto-note{margin:14px 0 0; font-size:13px; line-height:1.55; color:var(--muted); word-break:keep-all}
.wn + .wn{margin-top:16px}
.wn-v{font-size:13px; font-weight:700; color:var(--muted); margin-bottom:6px}
.wn ul{margin:0; padding-left:1.2em; display:flex; flex-direction:column; gap:6px; font-size:15px; line-height:1.55; word-break:keep-all}
.btn.quiet{background:transparent; color:var(--muted); font-weight:500}
.btn.quiet:hover{color:var(--ink); background:var(--line-2)}
.foot-links{display:flex; justify-content:center; align-items:center; gap:2px; margin-top:14px; color:var(--muted)}
.card.install p{margin:0 0 12px; font-size:14px; line-height:1.55; color:var(--ink-2); word-break:keep-all}
.card.install p:last-of-type{margin-bottom:0}
.card.install .btn{width:100%; margin-top:14px}
