/* MHD 공통 디자인 — 화면 틀만 담당. 메뉴는 .view 안쪽만 그린다 */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e3e6eb; --fg: #1d232b; --muted: #677281;
  --accent: #1f5fbf; --accent-soft: #e8f0fb; --danger: #c43d3d; --badge: #d9472b;
  --radius: 10px; --top: 56px; --rail: 76px;
  --font: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1318; --panel: #161b22; --line: #262d36; --fg: #e6e9ee; --muted: #8b95a3;
  --accent: #6aa4ff; --accent-soft: #15253d; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0f1318; --panel: #161b22; --line: #262d36; --fg: #e6e9ee; --muted: #8b95a3;
  --accent: #6aa4ff; --accent-soft: #15253d; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: hidden; }
body { background: var(--bg); color: var(--fg); font: 15px/1.6 var(--font); -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* 1줄 · 2줄 보기(영문 병기) */
.en { color: var(--muted); font-size: .82em; }
:root[data-lines="1"] .en { display: none; }

/* ---------- 머리줄 ---------- */
.topbar {
  position: fixed; inset: 0 0 auto; height: calc(var(--top) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 12px; z-index: 20;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; }
.mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--fg); color: var(--panel); font-size: 14px; }
.search { flex: 1; min-width: 0; max-width: 560px; margin-left: 8px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; color: var(--fg); }
.icon-btn { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); color: var(--fg); cursor: pointer; }
.icon-btn:hover { background: var(--bg); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--badge); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* ---------- 메뉴: PC 왼쪽 세로 / 휴대폰 아래 탭 ---------- */
.rail { position: fixed; top: calc(var(--top) + env(safe-area-inset-top, 0px)); bottom: 0; left: 0; width: var(--rail);
  padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; background: var(--panel); border-right: 1px solid var(--line); z-index: 10; }
.rail a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 8px;
  font-size: 12px; color: var(--muted); transition: background .15s, color .15s; }
.rail a .en { font-size: 10px; }
.rail a:hover { background: var(--bg); color: var(--fg); }
.rail a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.main { padding: calc(var(--top) + env(safe-area-inset-top, 0px) + 24px) max(16px, env(safe-area-inset-right, 0px)) 48px calc(var(--rail) + 24px); }
.view { max-width: 1080px; margin: 0 auto; transition: opacity .18s ease; }
.view.leaving { opacity: 0; }

@media (max-width: 720px) {
  .rail { top: auto; right: 0; width: auto; height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding: 4px max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
    flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line); }
  .rail a { flex: 1; padding: 6px 2px; }
  .rail a .en { display: none; }
  .main { padding: calc(var(--top) + env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right, 0px)) calc(84px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .brand span:last-child { display: none; }
  .search { margin-left: 0; }
}

/* ---------- 메뉴 본문이 쓰는 공통 부품 ---------- */
.page-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; text-wrap: balance; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a[aria-current] { color: var(--fg); border-color: var(--accent); font-weight: 600; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.list > div { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); min-width: 0; }
.list > div:first-child { border-top: 0; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.err-card { padding: 24px; border: 1px solid var(--danger); border-radius: var(--radius); background: var(--panel); }
.err-card h2 { margin: 0 0 8px; font-size: 17px; color: var(--danger); }

/* ---------- 로그인 ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.brand-lg { font-size: 22px; }
.brand-lg .mark { width: 36px; height: 36px; font-size: 18px; }
.login-sub { margin: -8px 0 4px; color: var(--muted); font-size: 13px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; }
.login-msg { min-height: 1.4em; margin: 0; color: var(--danger); font-size: 13px; }
.btn-primary { height: 40px; padding: 0 16px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.btn-ghost { height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--fg); font: inherit; cursor: pointer; }

/* ---------- ⚙ 설정 ---------- */
.sheet { width: min(360px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--fg); }
.sheet::backdrop { background: rgb(0 0 0 / .35); }
.sheet h2 { margin: 0 0 12px; font-size: 17px; }
.sheet fieldset { border: 0; padding: 0; margin: 0 0 14px; display: flex; gap: 14px; flex-wrap: wrap; }
.sheet legend { width: 100%; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.sheet-foot { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- 목표 카드 · 진행 막대 · 실행리스트(공통 부품) ---------- */
.stack { display: grid; gap: 12px; }
.goal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.goal-head h2 { margin: 0; font-size: 17px; flex: 1; min-width: 0; }
.pill { padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; white-space: nowrap; }
.goal-text { margin: 8px 0 2px; font-weight: 500; }
.north { margin: 0 0 12px; font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }
.bar-label { margin: 6px 0 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.checklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.checklist .tick { flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 2px; border: 1.5px solid var(--line); border-radius: 6px; font-size: 13px; color: #fff; }
.checklist li.done .tick { background: var(--accent); border-color: var(--accent); }
.checklist li.done .ct { color: var(--muted); }
.checklist .ct { min-width: 0; }
.when { font-size: 12px; }
.next { margin: 10px 0 0; font-size: 14px; }
.archived summary { cursor: pointer; padding: 8px 0; color: var(--muted); }
