/* ───────────────────────── 토큰 ───────────────────────── */
:root{
  --bg:#f2f2f7; --surface:#ffffff; --surface-2:#f9f9fb;
  --ink:#1c1c1e; --ink-2:#3a3a3c; --muted:#8e8e93; --line:#e5e5ea; --line-2:#efeff4;
  --accent:#0a7aff; --accent-soft:#e8f1ff; --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:#0a84ff; --accent-soft:#0d2a4d; --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:#0a84ff; --accent-soft:#0d2a4d; --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{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; min-height:100vh; min-height:100dvh}
.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; display:flex; align-items:baseline; gap:8px; flex-wrap:wrap}
.brand-en{font-size:15px; font-weight:600; color:var(--muted); letter-spacing:.01em}
.brand+.muted{margin-bottom:18px}

/* 로그인 화면 */
.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:16px; margin-bottom:32px}
.auth .msg{margin-top:14px; font-size:13px; line-height:1.5}

.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:#fff}
.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.plain{padding:calc(env(safe-area-inset-top,0px) + 16px) 16px 12px}
.topbar h2{font-size:28px; font-weight:800; letter-spacing:-.02em}
.topbar-row{display:flex; align-items:center; justify-content:space-between}
.date-title{font-size:20px; font-weight:700; letter-spacing:-.02em; padding:4px 10px; border-radius:8px}
.date-title:active{background:var(--line-2)}

.week{display:grid; grid-template-columns:repeat(7,1fr); gap:2px; margin-top:6px}
.day{display:flex; flex-direction:column; align-items:center; gap:3px; padding:6px 0 4px; border-radius:10px}
.day .dow{font-size:11px; color:var(--muted); font-weight:600}
.day .num{width:32px; height:32px; border-radius:50%; display:grid; place-items:center; font-weight:600; font-size:15px}
.day.today .num{color:var(--accent)}
.day.selected .num{background:var(--accent); color:#fff}
.day.sun .dow{color:var(--danger)}
.day .dot{width:5px; height:5px; border-radius:50%; background:var(--line); opacity:0}
.day.has .dot{opacity:1; background:var(--muted)}
.day.all-done .dot{background:var(--success)}

.people{display:flex; gap:10px; overflow-x:auto; padding:10px 2px 4px; scrollbar-width:none}
.people::-webkit-scrollbar{display:none}
.person{display:flex; flex-direction:column; align-items:center; gap:4px; flex:none; width:56px}
.person .ava{
  width:44px; height:44px; border-radius:50%; background:var(--surface); display:grid; place-items:center;
  font-size:22px; border:2px solid var(--line); transition:border-color .15s, transform .1s;
}
.person.selected .ava{border-color:var(--accent); transform:scale(1.05)}
.person .nm{font-size:11px; color:var(--muted); max-width:56px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.person.selected .nm{color:var(--ink); font-weight:600}

/* ───────────────────────── 할 일 목록 ───────────────────────── */
.group{margin-bottom:18px}
.group-head{display:flex; align-items:center; gap:8px; padding:4px 4px 6px}
.group-head .cat-dot{width:10px; height:10px; border-radius:50%; flex:none}
.group-head .cat-name{font-weight:700; font-size:15px}
.group-head .cat-count{color:var(--muted); font-size:13px; margin-left:auto}
.list{background:var(--surface); border-radius:var(--radius); overflow:hidden; box-shadow:var(--shadow)}
.list:empty{display:none}
.item{display:flex; align-items:center; gap:10px; padding:11px 14px; min-height:48px; position:relative}
.item+.item::before{content:""; position:absolute; left:48px; right:0; top:0; height:1px; background:var(--line-2)}
.item.plain+.item.plain::before{left:14px}
.check{
  width:24px; height:24px; flex:none; border-radius:50%; border:2px solid var(--line);
  display:grid; place-items:center; transition:all .15s; color:#fff; font-size:14px; font-weight:700;
}
.check.on{background:var(--cat,var(--accent)); border-color:var(--cat,var(--accent))}
.check.on::after{content:"✓"}
.check.ro{cursor:default}
.item .title{flex:1; min-width:0; word-break:break-word; display:flex; align-items:center; gap:6px; flex-wrap:wrap}
.item.done .title{color:var(--muted); text-decoration:line-through; text-decoration-color:var(--line)}
.item .tag{font-size:11px; color:var(--muted); background:var(--line-2); border-radius:6px; padding:1px 6px; white-space:nowrap}
.more{width:32px; height:32px; border-radius:50%; color:var(--muted); font-size:20px; display:grid; place-items:center; flex:none; letter-spacing:1px}
.more:active{background:var(--line-2)}
.reacts{display:flex; gap:4px; flex-wrap:wrap; margin-left:auto}
.react{
  display:inline-flex; align-items:center; gap:3px; font-size:13px; padding:2px 7px; border-radius:999px;
  background:var(--line-2); border:1px solid transparent;
}
.react.mine{background:var(--accent-soft); border-color:var(--accent)}
.react .n{font-size:11px; color:var(--muted)}
.react-add{width:28px; height:28px; border-radius:50%; background:var(--line-2); color:var(--muted); font-size:15px; display:grid; place-items:center; flex:none}

.add-row{display:flex; align-items:center; gap:10px; padding:8px 14px 8px 14px}
.add-row .plus{width:24px; height:24px; flex:none; border-radius:50%; color:var(--accent); display:grid; place-items:center; font-size:22px; line-height:1}
.add-row input{flex:1; min-width:0; background:none; border:0; outline:none; padding:6px 0}
.add-row input::placeholder{color:var(--muted)}

.home-footer{display:flex; flex-direction:column; gap:10px; margin-top:8px}
.home-footer .btn{width:100%}
.progress{display:flex; align-items:center; gap:10px; color:var(--muted); font-size:13px; padding:0 4px}
.progress .bar{flex:1; height:6px; background:var(--line-2); border-radius:3px; overflow:hidden}
.progress .bar i{display:block; height:100%; background:var(--success); border-radius:3px; transition:width .3s}

.empty{text-align:center; color:var(--muted); padding:48px 0 24px}
.empty-emoji{font-size:40px; margin-bottom:8px}

.section-title{font-size:13px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; margin:22px 4px 8px}
.friend{display:flex; align-items:center; gap:12px; padding:10px 14px}
.friend+.friend{border-top:1px solid var(--line-2)}
.friend .ava{width:40px; height:40px; border-radius:50%; background:var(--surface-2); display:grid; place-items:center; font-size:20px; flex:none}
.friend .nm{font-weight:600}
.friend .un{font-size:13px; color:var(--muted)}
.friend .acts{margin-left:auto; display:flex; gap:6px}
.cat-row .cat-dot{width:14px; height:14px; border-radius:50%; flex:none}
.form-category{margin-top:10px}

/* ───────────────────────── 탭바 ───────────────────────── */
.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}
.badge{position:absolute; top:8px; left:calc(50% + 6px); background:var(--danger); color:#fff; font-size:10px; font-weight:700; min-width:16px; height:16px; border-radius:8px; display:grid; place-items:center; padding:0 4px}

/* ───────────────────────── 시트 ───────────────────────── */
.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;
}
