:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #ff5a1f;
  --brand-soft: #fff0ea;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --gray: #9ca3af;
  --bar: #111827;
  --radius: 14px;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #151b26;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --line: #273042;
    --brand-soft: #3a1d12;
    --bar: #0b0f17;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--brand); text-decoration: none; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 10px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.danger { color: var(--danger); }
.pre { white-space: pre-wrap; }
.grow { flex: 1; min-width: 0; }

/* 상단바 / 탭바 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bar); color: #fff;
}
.topbar h1 { font-size: 19px; margin: 0; display: flex; align-items: center; gap: 6px; }
.topbar .back { color: #fff; font-size: 26px; line-height: 1; padding-right: 4px; }
#top-actions { display: flex; gap: 6px; }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; gap: 2px;
}
.tabbar a .ico { font-size: 20px; line-height: 1; }
.tabbar a.on { color: var(--brand); font-weight: 700; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.primary.danger { background: var(--danger); color: #fff; }
.topbar .btn { border-color: rgba(255,255,255,.25); background: transparent; color: #fff; }
.topbar .btn.primary { background: var(--brand); border-color: var(--brand); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row.end { justify-content: flex-end; }
.link { background: none; border: 0; padding: 2px 4px; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.link.danger { color: var(--danger); }

/* 카드 */
.card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
  text-align: left; font: inherit; cursor: pointer;
}
.card.session .time { display: flex; flex-direction: column; align-items: center; min-width: 48px; }
.card.session .time b { font-size: 17px; }
.card.session .time small { color: var(--muted); }
.card.st-done, .card.st-cancelled, .card.st-noshow { opacity: .62; }
.card.inactive { opacity: .55; }
.row-title { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-title.big { font-size: 20px; }

.chip { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.chip.lg { font-size: 14px; padding: 4px 12px; }
.chip.gray { background: var(--line); color: var(--muted); }

.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.b-scheduled { background: #e0ecff; color: #1d4ed8; }
.b-done { background: #dcfce7; color: var(--ok); }
.b-noshow { background: #fee2e2; color: var(--danger); }
.b-cancelled { background: var(--line); color: var(--muted); }

.caution { color: var(--warn); font-size: 13px; margin-top: 3px; }
.caution.box { background: #fff7e6; border: 1px solid #fde3b0; border-radius: 10px; padding: 8px 12px; color: #92400e; margin: 8px 0; }
@media (prefers-color-scheme: dark) { .caution.box { background: #2a2111; border-color: #5a4415; color: #fcd34d; } }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }

/* 진행률 */
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.progress.low span { background: var(--danger); }
.progress-label { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.progress-label b { color: var(--text); }
.progress-label .danger b { color: var(--danger); }

/* 오늘 */
.date-hero { font-weight: 700; font-size: 17px; margin: 4px 0 12px; }
.date-hero small { font-weight: 400; font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stats b { display: block; font-size: 24px; }
.stats small { color: var(--muted); font-size: 12px; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #e0ecff; color: #1e3a8a; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.banner.warn { background: #fee2e2; color: #7f1d1d; }
.empty { text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; }

/* 스케줄 */
.week-nav { display: flex; justify-content: space-between; margin-bottom: 8px; }
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px; }
.day { display: flex; flex-direction: column; align-items: center; padding: 6px 0; border-radius: 12px; border: 1px solid transparent; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.day small { color: var(--muted); font-size: 11px; }
.day b { font-size: 16px; }
.day i { font-style: normal; color: var(--brand); font-size: 10px; height: 12px; letter-spacing: 1px; }
.day.today b { color: var(--brand); }
.day.on { background: var(--brand); color: #fff; }
.day.on small, .day.on i, .day.on b { color: #fff; }

.timeline { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.slot { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed transparent; }
.slot.hour { border-top: 1px solid var(--line); }
.slot span { position: absolute; left: 8px; top: -8px; font-size: 11px; color: var(--muted); background: var(--surface); padding: 0 4px; }
.lanes { position: absolute; inset: 0 6px 0 56px; cursor: copy; }
.lanes:hover { background: repeating-linear-gradient(to bottom, transparent 0 17px, color-mix(in srgb, var(--line) 60%, transparent) 17px 18px); }
.block {
  position: absolute; overflow: hidden; text-align: left; font: inherit; font-size: 12.5px; line-height: 1.3;
  border: 0; border-left: 4px solid var(--brand); border-radius: 8px; padding: 3px 8px;
  background: var(--brand-soft); color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.block small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block.st-done { border-left-color: var(--ok); opacity: .7; }
.block.st-noshow { border-left-color: var(--danger); opacity: .7; }
.now { position: absolute; left: 50px; right: 0; border-top: 2px solid var(--danger); pointer-events: none; }
.now::before { content: ''; position: absolute; left: -5px; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* 회원 */
.searchbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.profile { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.links { display: flex; gap: 12px; margin-top: 4px; font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.panel h3:not(:first-child) { margin-top: 18px; }
.plain { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13.5px; }
.plain li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.notes { list-style: none; padding: 0; margin: 12px 0 0; }
.notes li { border-top: 1px solid var(--line); padding: 10px 0; }
.notes li.pinned { background: var(--brand-soft); margin: 0 -16px; padding: 10px 16px; }
.note-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.note-mini { font-size: 13px; margin: 6px 0; }

/* 폼 / 시트 */
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 4px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input, .toggle input { width: auto; margin: 0; }
label.btn { margin: 0; color: var(--text); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

dialog#sheet {
  width: min(560px, 100%); max-height: 92vh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--text);
}
@media (min-width: 640px) { dialog#sheet { margin: auto; border-radius: 20px; } }
dialog#sheet::backdrop { background: rgba(0, 0, 0, .45); }
#sheet-body { padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
#sheet-body h3 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 동기화 상태 / 로그인 */
.top-right { display: flex; align-items: center; gap: 8px; }
.sync-badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.12); color: #d1d5db; white-space: nowrap; }
.sync-badge:empty { display: none; }
.sync-badge::before { content: '●'; margin-right: 4px; }
.sync-badge.ok::before { color: #22c55e; }
.sync-badge.busy::before { color: #fbbf24; }
.sync-badge.off::before { color: var(--gray); }
.sync-badge.err::before { color: #f87171; }
body.auth .tabbar, body.auth .sync-badge { display: none; }
body.auth { padding-bottom: 0; }
.auth-card { max-width: 400px; margin: 24px auto; }
.auth-card .btn.primary { width: 100%; margin-top: 4px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 8px; }

/* 앱 설치 */
.banner.install { background: var(--brand-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); }
.banner.install small { color: var(--muted); }
.btn-row.tight { margin-top: 0; align-items: center; flex-wrap: nowrap; }
.install-inline { margin-top: 4px; font-size: 14px; color: var(--brand); }
.steps { padding-left: 20px; margin: 8px 0 12px; }
.steps li { margin-bottom: 10px; line-height: 1.6; }
.ico-inline { vertical-align: -4px; color: #2563eb; }
.url { font-family: ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; font-size: 13px; }
