/* 바탕(D안 · 손글씨 다이어리): 색 변수, 화면 배치, 프로필, 달력, 시간표, 하단 탭 */
:root {
  --fs: 1; /* 글자 크기 배율 (설정에서 바꾼다) */
  --paper: #FFFFFF; --ink: #2B2B2B; --onink: #FFFFFF; --sub: #63636B;
  --line: #B4B4BC; --line2: #D5D5DB; --soft: #F5F5F7; --red: #C4262C;
  /* 순위 형광펜: 1순위 빨강 · 2순위 노랑 · 3순위 파랑 · 4순위 회색 */
  --p1: #E5484D; --p2: #F2C94C; --p2line: #D9A400; --p3: #3E7BFA; --p4: #B4B4BC; --focus: #3E7BFA;
  --shadow: 0 10px 34px rgba(0, 0, 0, .14);
  --wob1: 52% 48% 55% 45% / 46% 54% 48% 52%; /* 손으로 그린 듯한 동그라미 */
  --wob2: 48% 52% 45% 55% / 55% 45% 52% 48%;
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --hand: 'Gaegu', 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', sans-serif;
  --hs: 1; /* 손글씨 글꼴마다 보이는 크기를 맞추는 배율 (설정의 글씨체, js/fonts.js) */
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #161618; --ink: #EDEDED; --onink: #161618; --sub: #A3A3AC;
  --line: #5C5C64; --line2: #3B3B41; --soft: #232326; --red: #FF8A8F;
  --p4: #6E6E77; --shadow: 0 10px 34px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
:root[data-theme="beige"] { /* 베이지: 누런 종이 다이어리 (글자 대비: 본문 11:1, 흐린 글자 5.5:1) */
  --paper: #F6EFE1; --ink: #3B3127; --onink: #F6EFE1; --sub: #6B5E4F;
  --line: #B8A78B; --line2: #DDD0B8; --soft: #EDE3CF; --red: #B0322B;
  --p1: #DE5A50; --p2: #EDC04B; --p2line: #C49612; --p3: #4775D1; --p4: #BBAE97; --focus: #4775D1;
  --shadow: 0 10px 34px rgba(90, 64, 30, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: calc(15px * var(--fs))/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { flex: none; }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--soft); }
.ring-btn { /* 손으로 그린 동그라미 버튼 */
  width: 24px; height: 24px; border: 1.6px solid var(--ink); border-radius: var(--wob1);
  display: inline-grid; place-items: center; flex: none;
}
.ring-btn:hover { background: var(--soft); }
.ring-btn svg { width: 13px; height: 13px; stroke-width: 2.4; }
.chip {
  font: 700 calc(18px * var(--fs) * var(--hs))/1.2 var(--hand); padding: 2px 14px 3px; border: 1.5px dashed var(--sub); border-radius: 999px;
  white-space: nowrap; flex: none;
}
.chip:hover { background: var(--soft); }
.chip.now { padding: 1px 12px 2px; border: 1.8px solid var(--ink); border-radius: var(--wob2); transform: rotate(-4deg); pointer-events: none; }
.empty-hint { font: calc(19px * var(--fs) * var(--hs))/1.3 var(--hand); color: var(--sub); padding: 14px 2px; margin: 0; }

/* ---------- 두 단 배치 (Mac) ---------- */
#app {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 40px;
  max-width: 1080px; margin: 0 auto; padding: 30px 28px 80px;
}
#side { /* 내용이 창보다 길어지면 왼쪽 단만 따로 스크롤된다 */
  position: sticky; top: 30px; align-self: start; max-height: calc(100vh - 60px); overflow: hidden auto;
  margin: -4px -8px; padding: 4px 8px;
}
#right { min-width: 0; }
#weekstrip, #page-timetable, #page-week, #page-habits { display: none; }
/* 달력 화면: 달력만 크게 본다 (프로필과 하루 화면은 접는다) */
body[data-tab="calendar"] #right, body[data-tab="calendar"] #profile { display: none; }
/* 주간 보기 · 습관 트래커: 왼쪽 달력을 접고 화면 전체를 쓴다 */
body[data-tab="week"] #main, body[data-tab="week"] #side,
body[data-tab="habits"] #main, body[data-tab="habits"] #side { display: none; }
body[data-tab="week"] #page-week, body[data-tab="habits"] #page-habits { display: block; }
body[data-tab="week"] #app, body[data-tab="habits"] #app { grid-template-columns: minmax(0, 1fr); }
body[data-tab="timetable"] #main { display: none; }
body[data-tab="timetable"] #page-timetable { display: block; }
#offline {
  position: sticky; top: 0; z-index: 40; text-align: center; padding: 4px;
  font: calc(17px * var(--fs) * var(--hs))/1.2 var(--hand); background: var(--soft); color: var(--sub); border-bottom: 1px dashed var(--line);
}

/* ---------- 프로필·디데이 ---------- */
.prof { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 50px; height: 50px; border: 2px solid var(--ink); border-radius: var(--wob1); flex: none;
  display: grid; place-items: center; font: 700 calc(26px * var(--fs) * var(--hs))/1 var(--hand);
  padding: 0; overflow: hidden; background: var(--paper); cursor: pointer; /* 누르면 사진을 바꾼다 */
}
.avatar:hover { background: var(--soft); }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.crop { display: grid; place-items: center; margin: 4px 0 12px; }
.crop canvas { width: 220px; height: 220px; border: 2px solid var(--ink); border-radius: var(--wob1); touch-action: none; cursor: grab; }
.crop-zoom { display: block; width: 100%; margin: 0 0 4px; accent-color: var(--ink); }
.prof-main { flex: 1; min-width: 0; }
.prof-name { font: 700 calc(26px * var(--fs) * var(--hs))/1.05 var(--hand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dday-chip { display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%; font-size: calc(13px * var(--fs)); color: var(--sub); }
.dday-chip:hover { color: var(--ink); }
.dday-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dday-chip b { font: 700 calc(20px * var(--fs) * var(--hs))/1 var(--hand); color: var(--red); flex: none; }

/* ---------- 달력 ---------- */
#calendar { margin-top: 22px; }
.cal-head { display: flex; align-items: center; gap: 2px; margin-bottom: 8px; }
.cal-title { flex: 1; font: 700 calc(25px * var(--fs) * var(--hs))/1.1 var(--hand); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 2px 12px; }
.fdot { width: 18px; height: 18px; border: 1.6px solid var(--ink); border-radius: var(--wob1); background: var(--c); }
.fdot:nth-child(even) { border-radius: var(--wob2); }
.fdot.all { background: var(--ink); }
.fdot.on { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.8px var(--ink); }
.cal-wd, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-wd { font: calc(17px * var(--fs) * var(--hs))/1.1 var(--hand); color: var(--sub); text-align: center; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.cal-grid { padding-top: 4px; }
.cal-day {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 62px; padding: 6px 0 2px; border-radius: 12px; min-width: 0;
}
.cal-day:hover { background: var(--soft); }
.cal-day.drop { background: var(--soft); box-shadow: inset 0 0 0 2px var(--ink); }
.cell { position: relative; width: 36px; height: 36px; display: grid; place-items: center; }
.blob { position: absolute; border-radius: var(--wob1); } /* 완료한 카테고리 색: 형광펜 동그라미 */
.blob + .blob { border-radius: var(--wob2); }
.ring { position: absolute; inset: 0; border-radius: var(--wob2); transform: rotate(-8deg); }
.cal-day.sel .ring { border: 1.5px dashed var(--sub); }
.cal-day.today .ring { border: 2px solid var(--ink); }
.dn { position: relative; font: 700 calc(20px * var(--fs) * var(--hs))/1 var(--hand); }
.cnt { /* 남은 할 일 개수 */
  position: absolute; top: -4px; right: -7px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--ink); color: var(--onink); font-size: calc(10px * var(--fs)); font-weight: 700; line-height: 15px; text-align: center;
}
.cnt.pre { background: var(--paper); color: var(--sub); border: 1px dashed var(--sub); line-height: 13px; } /* 아직 안 생긴 반복 할 일 */
.ok { position: absolute; top: -6px; right: -8px; display: grid; }
.ok svg { width: 15px; height: 15px; stroke-width: 3; }
.cell .flag { position: absolute; top: -7px; left: -7px; display: grid; }
.cell .flag svg { width: 14px; height: 14px; fill: var(--p1); }
.bars { display: flex; gap: 2px; align-items: center; height: 10px; }
.bars i { width: 8px; height: 3px; border-radius: 2px; background: var(--c); }
.bars b { font-size: calc(10px * var(--fs)); font-weight: 700; color: var(--sub); line-height: 10px; }
/* 큰 달력(Mac의 달력 화면)에서만 보이는 그날 일정 · 할 일 제목 */
.cal-items { display: none; flex-direction: column; min-width: 0; }
.ci { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: calc(12px * var(--fs))/1.5 var(--font); }
.ci i { display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--c); vertical-align: 1px; }
.ci.ev i { width: 9px; height: 4px; border-radius: 2px; vertical-align: 2px; } /* 일정은 짧은 막대 */
.ci.done { color: var(--sub); text-decoration: line-through; }
.ci.pre { color: var(--sub); } /* 아직 안 생긴 반복 할 일 */
.ci.pre i { background: none; border: 1.2px solid var(--c); }
.ci.more { font: calc(14px * var(--fs) * var(--hs))/1.4 var(--hand); color: var(--sub); }

/* 한 달 돌아보기: 카테고리별 완료 개수 */
.month-sum { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.ms-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.ms-head h3 { flex: 1; margin: 0; font: 700 calc(21px * var(--fs) * var(--hs))/1.1 var(--hand); }
.ms-head span { font-size: calc(12px * var(--fs)); color: var(--sub); }
.ms-row { display: grid; grid-template-columns: calc(88px * var(--fs)) minmax(0, 1fr) calc(30px * var(--fs)); align-items: center; gap: 8px; min-height: 26px; }
.ms-name { font: calc(18px * var(--fs) * var(--hs))/1.15 var(--hand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-bar i { display: block; height: 10px; border-radius: 3px; background: var(--c); opacity: .5; transform: rotate(-.5deg); }
.ms-row b { font: 700 calc(18px * var(--fs) * var(--hs))/1 var(--hand); text-align: right; }
.ms-rest { margin: 4px 0 0; font-size: calc(12px * var(--fs)); color: var(--sub); }

/* ---------- 날짜 머리 ---------- */
#dayhead { display: flex; align-items: center; gap: 10px; min-height: 52px; margin-bottom: 14px; }
.day-title { margin: 0; font: 700 calc(34px * var(--fs) * var(--hs))/1.1 var(--hand); }
#dayhead .sp { flex: 1; }
#dayhead .icon-btn + .icon-btn { margin-left: -8px; }

/* ---------- 시간표 ---------- */
.tt-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 52px; margin-bottom: 14px; }
.tt-head h1 { margin: 0; font: 700 calc(34px * var(--fs) * var(--hs))/1.1 var(--hand); }
.tt-head .sp { flex: 1; }
.tt-sem {
  max-width: 100%; padding: 3px 10px; border: 1.6px solid var(--ink); border-radius: 14px 18px 12px 16px;
  background: var(--paper); font: 700 calc(20px * var(--fs) * var(--hs))/1.2 var(--hand);
}
.tt-days {
  display: grid; grid-template-columns: 40px repeat(var(--days), minmax(0, 1fr));
  font: 700 calc(19px * var(--fs) * var(--hs))/1.1 var(--hand); text-align: center; padding-bottom: 6px; border-bottom: 1px dashed var(--line);
}
.tt-days .now { text-decoration: underline wavy var(--p1) 1.5px; text-underline-offset: 3px; }
.tt-body { display: grid; grid-template-columns: 40px minmax(0, 1fr); margin-top: 10px; }
.tt-times span { display: block; height: var(--hh); padding-right: 8px; font: calc(16px * var(--fs) * var(--hs))/1 var(--hand); color: var(--sub); text-align: right; transform: translateY(-7px); }
.tt-cols { position: relative; display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); height: calc(var(--hh) * var(--hours)); }
.tt-lines { position: absolute; inset: 0; pointer-events: none; }
.tt-lines i { display: block; height: var(--hh); border-top: 1px dashed var(--line2); }
.tt-col { position: relative; border-left: 1px dashed var(--line2); }
.tt-col:last-child { border-right: 1px dashed var(--line2); }
.tt-class {
  position: absolute; z-index: 0; overflow: hidden; padding: 4px 6px; text-align: left;
  border: 1.6px solid var(--ink); border-radius: 12px 10px 13px 9px; background: var(--paper);
  font-size: calc(11px * var(--fs)); line-height: 1.25;
}
.tt-class::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--c); opacity: .38; }
.tt-class b { display: block; font-size: calc(13px * var(--fs)); font-weight: 600; overflow-wrap: anywhere; }
.tt-class span { display: block; }
.tt-foot { margin-top: 12px; font-size: calc(12px * var(--fs)); color: var(--sub); }

/* ---------- 주간 보기: 한 주 7일의 할 일 ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.wk-day { min-width: 0; min-height: 240px; padding: 6px 7px 8px; border: 1.6px solid var(--ink); border-radius: 14px 12px 16px 12px; }
.wk-day:nth-child(even) { border-radius: 12px 16px 12px 14px; }
.wk-head {
  display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 2px 2px 6px; margin-bottom: 4px;
  border-bottom: 1px dashed var(--line); font-family: var(--hand); line-height: 1.1; text-align: left;
}
.wk-head b { font-size: calc(19px * var(--fs) * var(--hs)); }
.wk-num { position: relative; z-index: 0; font-size: calc(22px * var(--fs) * var(--hs)); font-weight: 700; }
.wk-day.today .wk-num::before { /* 오늘은 노란 형광펜 */
  content: ''; position: absolute; z-index: -1; left: -4px; right: -4px; bottom: 1px; height: 9px;
  border-radius: 3px; background: var(--p2); opacity: .7; transform: rotate(-1deg);
}
.wk-head em { margin-left: auto; font-style: normal; font-size: calc(15px * var(--fs)); color: var(--sub); }
.wk-ev { display: flex; align-items: center; gap: 5px; padding: 1px 2px; font-size: calc(12px * var(--fs)); color: var(--sub); }
.wk-ev i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.wk-ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-list { list-style: none; margin: 4px 0 0; padding: 0; min-height: 70px; display: flex; flex-direction: column; }

/* ---------- 습관 트래커: 할 일과 따로 있는 화면. 줄은 습관, 칸은 그 달의 날짜 ---------- */
:root { --hb-name: calc(176px * var(--fs)); --hb-min: 22px; } /* 이름 칸 너비 · 날짜 칸 최소 너비 (끌 때 떠다니는 줄도 같은 값을 쓴다) */
.hb-nav { display: flex; align-items: center; gap: 10px; margin-left: auto; } /* 이전·다음 화살표 묶음: 좁아서 아랫줄로 내려가도 둘이 함께 오른쪽에 붙는다 */
.hb-nav .icon-btn + .icon-btn { margin-left: -8px; }
#page-habits .add-row { margin-top: 12px; }
.hb-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 2px; }
.hb-chip { /* 오늘 줄: 오늘 하는 습관을 크게 눌러 체크 */
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 38px; padding: 3px 14px 4px 10px;
  border: 1.5px dashed var(--line); border-radius: 999px; font: 700 calc(19px * var(--fs) * var(--hs))/1.2 var(--hand); text-align: left;
}
.hb-chip:hover { background: var(--soft); }
.hb-chip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-chip.done { border: 1.6px solid var(--ink); }
.hb-check { position: relative; width: 18px; height: 18px; border: 1.6px solid var(--ink); border-radius: var(--wob1); flex: none; color: transparent; }
.hb-check svg { position: absolute; left: 0; top: -6px; width: 18px; height: 18px; stroke-width: 2.8; pointer-events: none; }
.hb-chip.done .hb-check { background: var(--c); color: var(--ck, var(--ink)); }
.hb-none { margin: 2px 2px 0; font: calc(17px * var(--fs) * var(--hs))/1.3 var(--hand); color: var(--sub); }
.hb-wrap { margin-top: 18px; padding-bottom: 8px; overflow-x: auto; overscroll-behavior-x: contain; }
.hb-grid { min-width: calc(var(--hb-name) + var(--hb-cols) * var(--hb-min)); }
.hb-row {
  display: grid; grid-template-columns: var(--hb-name) repeat(var(--hb-cols), minmax(var(--hb-min), 1fr));
  min-height: 46px; border-bottom: 1px dashed var(--line2); background: var(--paper);
}
.hb-head { min-height: 0; border-bottom: 1px dashed var(--line); }
.hb-corner, .hb-name { /* 표를 옆으로 밀어도 이름 칸은 왼쪽에 붙어 있다 */
  position: sticky; left: 0; z-index: 2; min-width: 0; background: var(--paper); border-right: 1px dashed var(--line2);
}
.hb-name {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 1px; padding: 4px 8px 4px 0;
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hb-name:hover { background: var(--soft); }
.hb-name b { position: relative; z-index: 0; max-width: 100%; padding: 0 5px; font: 700 calc(21px * var(--fs) * var(--hs))/1.15 var(--hand); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-name b::before { /* 습관 색 형광펜 */
  content: ''; position: absolute; z-index: -1; left: 0; right: 0; bottom: 2px; height: 9px;
  border-radius: 3px; background: var(--c); opacity: .35; transform: rotate(-1deg);
}
.hb-name small { max-width: 100%; padding: 0 5px; font-size: calc(11px * var(--fs)); line-height: 1.3; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-day { display: grid; justify-items: center; align-content: end; gap: 2px; min-width: 0; padding: 5px 0 6px; font-family: var(--hand); line-height: 1; }
.hb-day i { font-style: normal; font-size: calc(14px * var(--fs) * var(--hs)); color: var(--sub); }
.hb-day b { position: relative; z-index: 0; font-size: calc(17px * var(--fs) * var(--hs)); }
.hb-day.now b::before { /* 오늘은 노란 형광펜 */
  content: ''; position: absolute; z-index: -1; left: -3px; right: -3px; bottom: 0; height: 8px;
  border-radius: 3px; background: var(--p2); opacity: .7; transform: rotate(-1deg);
}
.hb-cell { display: grid; place-items: center; min-width: 0; }
.hb-cell.now, .hb-day.now { background: var(--soft); } /* 오늘 칸은 위에서 아래로 옅은 띠 */
.hb-day.now { border-radius: 9px 9px 0 0; }
.hb-cell.ws, .hb-day.ws { border-left: 1px dashed var(--line2); } /* 한 주가 시작하는 칸 */
.hb-cell i { /* 손으로 그린 동그라미: 하는 날 */
  width: 20px; height: 20px; border: 1.5px solid var(--line); border-radius: var(--wob1);
  display: grid; place-items: center; color: transparent;
}
.hb-cell:nth-child(even) i { border-radius: var(--wob2); }
.hb-cell i svg { width: 13px; height: 13px; stroke-width: 3.2; }
.hb-cell.done i { border-color: var(--ink); background: var(--c); color: var(--ck, var(--ink)); } /* 한 날: 습관 색으로 칠한다 */
.hb-cell:disabled { cursor: default; }
.hb-cell:disabled i { border: 1.5px dashed var(--line2); } /* 아직 오지 않은 날 */
.hb-cell.off i { width: 4px; height: 4px; border: 0; border-radius: 50%; background: var(--line2); } /* 쉬는 날 */
.hb-cell:focus-visible { outline-offset: -3px; }
@media (hover: hover) { button.hb-cell:not(:disabled):hover i { border-color: var(--ink); } }

/* ---------- 디데이·설정: Mac에서는 가운데 창 ---------- */
.panel, #panel-backdrop { display: none; }
#panel-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 50; }
.panel {
  position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(460px, calc(100vw - 32px)); max-height: min(680px, calc(100vh - 48px)); overflow: auto;
  background: var(--paper); border: 1.8px solid var(--ink); border-radius: 20px 16px 22px 14px;
  box-shadow: var(--shadow); padding: 22px;
}
body[data-panel="dday"] #page-dday, body[data-panel="settings"] #page-settings, body[data-panel="cats"] #page-cats,
body[data-panel="dday"] #panel-backdrop, body[data-panel="settings"] #panel-backdrop, body[data-panel="cats"] #panel-backdrop { display: block; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h2 { flex: 1; margin: 0; font: 700 calc(30px * var(--fs) * var(--hs))/1.1 var(--hand); }

/* ---------- 폰: 한 단 + 하단 탭 ---------- */
@media (max-width: 767px) {
  #app { display: block; padding: max(18px, env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom)); }
  #side { position: static; max-height: none; overflow: visible; margin: 0; padding: 0; }
  #calendar, #weekstrip { margin-top: 16px; }
  #weekstrip { display: block; }
  #right { margin-top: 12px; }
  body[data-tab="today"] #calendar { display: none; }
  body[data-tab="calendar"] #weekstrip { display: none; }
  body[data-tab="timetable"] #side { display: none; }
  body[data-tab="timetable"] #right, body[data-tab="week"] #right, body[data-tab="habits"] #right { margin-top: 0; }
  :root { --hb-name: calc(112px * var(--fs)); --hb-min: 32px; } /* 습관 표: 한 화면에 일주일쯤 보이고 옆으로 민다 */
  .hb-row { min-height: 48px; }
  .hb-name b { font-size: calc(17px * var(--fs)); }
  .hb-name small { white-space: normal; } /* 좁은 이름 칸에서는 기록 글자를 두 줄로 */
  .week { grid-template-columns: minmax(0, 1fr); } /* 폰에서는 날짜별로 아래로 이어진다 */
  .wk-day { min-height: 0; }
  .week-list { min-height: 20px; }
  body[data-panel="dday"] #app, body[data-panel="settings"] #app, body[data-panel="cats"] #app { display: none; }
  .tt-head h1 { font-size: calc(30px * var(--fs)); }
  #dayhead { flex-wrap: wrap; gap: 4px 8px; }
  .day-title { font-size: calc(27px * var(--fs)); white-space: nowrap; }
  #dayhead .chip { font-size: calc(16px * var(--fs)); padding: 1px 9px 2px; }
  /* 좁은 순위 칸에서는 기준 글자를 이름 아래 줄로 내린다 */
  .pri { padding: 8px 10px; min-height: 104px; }
  .pri-head { flex-wrap: wrap; gap: 0 8px; }
  .pri-head b { order: 1; font-size: calc(21px * var(--fs) * var(--hs)); }
  .pri-head em { order: 2; }
  .pri-head span { order: 3; flex-basis: 100%; font-size: calc(15px * var(--fs) * var(--hs)); }
  #calendar .cal-day { min-height: 68px; }
  #panel-backdrop { display: none !important; }
  .panel {
    position: static; transform: none; width: auto; max-height: none; box-shadow: none; border: 0; border-radius: 0;
    padding: max(18px, env(safe-area-inset-top)) 16px calc(88px + env(safe-area-inset-bottom));
  }
  .panel .panel-close, .only-wide { display: none !important; }
  #tabs {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); position: fixed; z-index: 45; left: 0; right: 0; bottom: 0;
    background: var(--paper); border-top: 1.5px dashed var(--sub); padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  }
  #tabs button { display: grid; justify-items: center; gap: 1px; min-height: 52px; padding: 5px 0; font: calc(16px * var(--fs) * var(--hs))/1.1 var(--hand); color: var(--sub); }
  #tabs button.on { color: var(--ink); font-weight: 700; }
  #tabs button span { position: relative; z-index: 0; }
  #tabs button.on span::before {
    content: ''; position: absolute; z-index: -1; left: -4px; right: -4px; bottom: 1px; height: 8px;
    border-radius: 3px; background: var(--p2); opacity: .7; transform: rotate(-1deg);
  }
  #tabs svg { width: 22px; height: 22px; }
  #tabs button { overflow: hidden; white-space: nowrap; } /* 긴 메뉴 이름이 옆 칸으로 넘치지 않게 */
  html:lang(en) #tabs button { font-size: calc(14px * var(--fs) * var(--hs)); }
  html:lang(ja) #tabs button { font-size: calc(11.5px * var(--fs)); } /* 일본어 글자는 손글씨 글꼴이 아니라 크기 맞춤(hs)을 곱하지 않는다 */
  .tt-class { padding: 3px 4px; }
  .tt-class b { font-size: calc(12px * var(--fs)); }
  input, textarea, select { font-size: 16px !important; } /* iOS 확대 방지 */
}
/* ---------- Mac: 위쪽 메뉴 + 큰 달력 화면 ---------- */
@media (min-width: 768px) {
  .only-narrow { display: none !important; }
  #offline { position: static; }
  #tabs { /* 투두 · 습관 · 달력 · 시간표 · 디데이 · 설정. 화면을 내려도 위에 붙어 있다 */
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 4px;
    max-width: 1080px; margin: 0 auto; padding: 10px 20px 8px; background: var(--paper); border-bottom: 1.5px dashed var(--line);
  }
  #tabs button {
    display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 4px 13px 5px;
    border-radius: 12px 14px 11px 13px; font: calc(20px * var(--fs) * var(--hs))/1.1 var(--hand); color: var(--sub);
  }
  #tabs button:hover { background: var(--soft); color: var(--ink); }
  #tabs button.on { color: var(--ink); font-weight: 700; }
  #tabs button span { position: relative; z-index: 0; }
  #tabs button.on span::before { /* 지금 화면은 노란 형광펜 */
    content: ''; position: absolute; z-index: -1; left: -4px; right: -4px; bottom: 0; height: 9px;
    border-radius: 3px; background: var(--p2); opacity: .7; transform: rotate(-1deg);
  }
  #tabs svg { width: 18px; height: 18px; }
  #app { padding-top: 22px; }
  #side { top: 78px; max-height: calc(100vh - 100px); } /* 메뉴 아래에 붙는다 */

  /* 달력 화면: 달력이 화면 전체를 쓰고, 칸마다 그날 일정과 할 일 제목이 보인다 */
  body[data-tab="calendar"] #app { grid-template-columns: minmax(0, 1fr); }
  body[data-tab="calendar"] #side { position: static; max-height: none; overflow: visible; margin: 0; padding: 0; }
  body[data-tab="calendar"] #calendar { margin-top: 0; }
  body[data-tab="calendar"] .cal-head { min-height: 52px; margin-bottom: 10px; gap: 8px; }
  body[data-tab="calendar"] .cal-head .icon-btn + .icon-btn { margin-left: -8px; }
  body[data-tab="calendar"] .cal-title { font-size: calc(34px * var(--fs)); }
  body[data-tab="calendar"] .cal-wd { font-size: calc(19px * var(--fs)); }
  body[data-tab="calendar"] .cal-grid { padding-top: 0; border-left: 1px dashed var(--line2); }
  body[data-tab="calendar"] .cal-grid > * { border-right: 1px dashed var(--line2); border-bottom: 1px dashed var(--line2); }
  body[data-tab="calendar"] .cal-day { align-items: stretch; gap: 4px; min-height: 124px; padding: 6px 8px 8px; border-radius: 0; text-align: left; }
  body[data-tab="calendar"] .cal-day .cell { align-self: flex-start; }
  body[data-tab="calendar"] .bars { display: none; }
  body[data-tab="calendar"] .cal-items { display: flex; }
  body[data-tab="calendar"] .month-sum { max-width: 420px; }
}
