:root {
  --bg: #0b1020;
  --card: #151b2e;
  --card2: #1d2540;
  --line: #2a3354;
  --text: #e8ecf8;
  --muted: #8b95b5;
  --me: #3b82f6;
  --lili: #ec4899;
  --ok: #22c55e;
  --bad: #ef4444;
  --accent: #8b5cf6;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Hiragino Sans', 'Segoe UI', sans-serif; }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.center { text-align: center; }
.err { color: var(--bad); min-height: 1em; font-size: 14px; }

button { cursor: pointer; border: 0; border-radius: 12px; padding: 10px 14px; background: var(--card2); white-space: nowrap; }
button.primary { background: linear-gradient(135deg, var(--accent), #6366f1); font-weight: 700; }
button.ghost { background: transparent; }
button.small { padding: 6px 10px; font-size: 13px; }
button.block { width: 100%; margin-top: 12px; padding: 14px; }
button.danger { background: #3a1620; color: #fca5a5; }

input[type=password], input[type=number], input[type=date], input[type=text] {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); margin-top: 6px;
}
label { display: block; margin: 12px 0; font-size: 14px; color: var(--muted); }
label input { color: var(--text); }

/* 로그인 */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); padding: 28px; border-radius: 20px; text-align: center; }
.login-card h1 { font-size: 22px; margin: 0 0 8px; }
.who { display: flex; gap: 10px; margin: 16px 0; }
.who-btn { flex: 1; padding: 16px; font-size: 18px; border: 2px solid transparent; }
.who-btn.sel[data-user=me] { border-color: var(--me); background: #13254a; }
.who-btn.sel[data-user=lili] { border-color: var(--lili); background: #3d1630; }
.login-card .primary { width: 100%; margin-top: 12px; padding: 14px; }

/* 레이아웃 */
#app { max-width: 720px; margin: 0 auto; padding-bottom: 140px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); }
.topbar .title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { padding: 0 12px; }
.card { background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }

/* 요약 카드 */
.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.sc { background: var(--card); border-radius: 16px; padding: 12px; border-top: 3px solid var(--c); }
.sc .n { font-size: 13px; color: var(--muted); }
.sc .big { font-size: 22px; font-weight: 800; margin: 2px 0; }
.sc .row { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.sc .carry { font-weight: 700; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* 캘린더 */
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head h2 { font-size: 18px; margin: 8px 0; }
.cal-head button { font-size: 24px; padding: 4px 14px; }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow div { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.sat { color: #60a5fa !important; }
.sun { color: #f87171 !important; }
.day { background: var(--card); border-radius: 10px; min-height: 66px; padding: 4px 3px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; position: relative; border: 1px solid transparent; overflow: hidden; }
.day.other { opacity: 0.35; }
.day.today { border-color: var(--accent); }
.day.measure .dn::after { content: ''; display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: #60a5fa; margin-left: 3px; vertical-align: middle; }
.day .dn { font-size: 11px; color: var(--muted); padding-left: 2px; }
.day .w { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 3px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day .w.me { background: rgba(59, 130, 246, 0.22); color: #bfdbfe; }
.day .w.lili { background: rgba(236, 72, 153, 0.22); color: #fbcfe8; }
.day .cam { position: absolute; top: 3px; right: 3px; font-size: 9px; }
@media (min-width: 560px) { .day { min-height: 82px; } .day .w { font-size: 13px; } .day .dn { font-size: 13px; } }

/* 주간 */
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; background: transparent; padding: 10px; }
.seg button.sel { background: var(--card2); font-weight: 700; box-shadow: inset 0 -2px 0 var(--c); }
.week { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; border-left: 4px solid var(--line); }
.week.ok { border-left-color: var(--ok); }
.week.fail { border-left-color: var(--bad); }
.week.progress { border-left-color: var(--accent); }
.week .top { display: flex; justify-content: space-between; align-items: center; }
.week .top b { font-size: 15px; }
.week .badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--card2); }
.week.ok .badge { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.week.fail .badge { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.week.progress .badge { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
.week .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.week .grid div b { display: block; color: var(--text); font-size: 14px; }
.week .dates { font-size: 11px; color: var(--muted); }

/* 그래프 */
.chart svg { width: 100%; height: auto; display: block; }
.chart .lg { font-size: 12px; color: var(--muted); display: flex; gap: 12px; margin-top: 4px; }

/* FAB / 네비 */
.fab { position: fixed; right: max(18px, calc(50% - 342px)); bottom: 84px; width: 58px; height: 58px; border-radius: 50%; font-size: 30px; background: linear-gradient(135deg, var(--accent), #6366f1); box-shadow: 0 8px 24px rgba(99, 102, 241, 0.45); z-index: 20; padding: 0; }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(17, 24, 39, 0.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 15; }
.bottom-nav button { flex: 1; background: transparent; border-radius: 0; display: flex; flex-direction: column; align-items: center; font-size: 18px; padding: 8px 0; opacity: 0.55; }
.bottom-nav button span { font-size: 11px; margin-top: 2px; }
.bottom-nav button.active { opacity: 1; }

/* 모달 */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 16px 18px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 560px) { .modal { align-items: center; } .sheet { border-radius: 22px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h3 { margin: 0; }
.close { font-size: 18px; }
.upload { border: 2px dashed var(--line); border-radius: 14px; padding: 18px; text-align: center; color: var(--text); cursor: pointer; }
.upload input { display: none; }
.preview { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: #000; }

.entry { display: flex; gap: 12px; align-items: center; background: var(--card2); border-radius: 14px; padding: 10px; margin: 10px 0; border-left: 4px solid var(--c); }
.entry img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; cursor: zoom-in; background: #000; }
.entry .noimg { width: 76px; height: 76px; border-radius: 10px; background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.entry .info { flex: 1; }
.entry .info .wt { font-size: 22px; font-weight: 800; }
.entry .info .nm { font-size: 13px; color: var(--muted); }
.entry .acts { display: flex; flex-direction: column; gap: 6px; }

.photo-view { align-items: center; background: rgba(0, 0, 0, 0.92); }
.photo-view img { max-width: 100%; max-height: 100%; }

.toast { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); background: #111827; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 100; font-size: 14px; }

/* 언어 선택 */
.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lang-switch { display: inline-flex; background: var(--card); border-radius: 10px; padding: 3px; gap: 2px; }
.lang-switch button { padding: 5px 8px; font-size: 12px; background: transparent; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.lang-switch button.sel { background: var(--card2); color: var(--text); font-weight: 700; }
.login-card .lang-switch { margin-bottom: 14px; }
