:root {
  --text: #25312C;
  --muted: #7E8982;
  --bg: #F5F4EF;
  --card: #FFFFFF;
  --line: #E6E8E1;
  --green: #466B58;
  --green-soft: #EAF0E9;
  --reset: #F2E7D5;
  --today-dot: #E0975A;
  --danger: #B5574A;
  --radius: 18px;
  --pad: 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", Roboto, "Noto Sans KR", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
html { height: 100%; }
body { min-height: 100%; }

/* 가늘고 둥근 스크롤바 */
* { scrollbar-width: thin; scrollbar-color: #CFD4CB transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #CFD4CB;
  border-radius: 999px;
  border: 3px solid var(--bg);
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #AEB6AD; background-clip: padding-box; }
textarea::-webkit-scrollbar-thumb { border-color: var(--card); }
::-webkit-scrollbar-corner { background: transparent; }
::selection { background: #D6E3D6; }

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ================= 앱 셸: 화면 높이에 꽉 차고, 각 칸이 따로 스크롤 ================= */
.app {
  position: relative;
  height: 100vh;
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- 상단바 ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 2px 2px 0;
}
.topbar-left { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
.logo-btn {
  flex: 0 0 auto;
  padding: 0; border: none; background: none;
  border-radius: 10px; cursor: zoom-in; line-height: 0;
}
.logo-btn:hover .logo { border-color: var(--green); }
.logo-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.logo {
  display: block;
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

/* 로고 크게 보기 */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(37, 49, 44, 0.72);
  cursor: zoom-out;
}
.lightbox img {
  width: min(70vmin, 520px); height: auto;
  border-radius: 24px;
  -webkit-user-drag: none;
}
.lightbox-hint { color: rgba(255, 255, 255, 0.75); font-size: 13px; }
.brand { font-size: 12px; color: var(--muted); letter-spacing: -0.01em; line-height: 1.3; }
.greet { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.greet-sub { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.topbar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.status-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
  white-space: nowrap;
}
.status-btn:hover, .status-btn:focus-visible { border-color: var(--green); color: var(--green); outline: none; }
.status-btn.is-synced { color: var(--green); }

/* 동기화 패널: 상단바 아래로 떠서 열림 */
.sync-panel {
  position: absolute;
  right: 16px;
  top: 58px;
  z-index: 30;
  width: min(460px, calc(100vw - 32px));
  padding: 16px 18px;
  box-shadow: 0 8px 24px rgba(37, 49, 44, 0.08);
}
.sync-row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.sync-current {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px;
  background: var(--green-soft); border-radius: 12px;
}
.sync-current code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px; color: var(--green); letter-spacing: 0.04em; word-break: break-all;
}
.sync-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.sync-backup {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.sync-server, .sync-phone {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.sync-server .inline-join { flex: 1 1 auto; }
.sync-phone p { margin: 0; line-height: 1.5; }
.inline-join { display: flex; gap: 8px; flex: 1 1 240px; }
.inline-join input { flex: 1; min-width: 0; }

/* ---------- 버튼 ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 9px 14px;
  min-height: 40px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #FAFAF7; border-color: #D5D9D0; }
.btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: #3C5D4C; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--green-soft); }
.btn.reset { background: var(--reset); border-color: var(--reset); }
.btn.reset:hover { background: #ECDFC8; }
.btn.small { padding: 6px 12px; min-height: 32px; font-size: 13px; border-radius: 10px; }
.btn.icon { width: 38px; padding: 0; font-size: 20px; line-height: 1; min-height: 36px; }
.btn.link {
  border: none; background: none; padding: 4px 6px; min-height: 0;
  color: var(--muted); font-size: 13px; border-radius: 8px;
}
.btn.link:hover { color: var(--green); background: var(--green-soft); }
.btn.link.danger:hover { color: var(--danger); background: #F7ECEA; }

/* ---------- 탭 ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--green-soft);
  border-radius: 999px;
  flex: 0 0 auto;
}
.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 16px;
  min-height: 36px;
  cursor: pointer;
  font-weight: 500;
}
.tab:hover { color: var(--green); }
.tab:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.tab.is-active { background: var(--card); color: var(--green); font-weight: 600; }
.tabs.mini { margin: 10px 0 10px; }
.tabs.mini .tab { padding: 5px 13px; min-height: 30px; font-size: 13px; }

/* ---------- 본문 2열 ---------- */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: stretch;
}
.main-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.side-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}
.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  min-width: 0;
  flex: 0 0 auto;
}
.card h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.card.tint { background: var(--green-soft); border-color: #DCE5DB; }
.card.tint p { margin-top: 6px; font-size: 14px; }
.card.tint .emph { color: var(--green); font-weight: 600; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 달력: 남은 높이를 전부 사용 ---------- */
.calendar-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.cal-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 10px;
}
.cal-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.cal-title { font-size: 20px; }
.hint { margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav .btn { min-height: 36px; padding: 6px 12px; }

.weekdays, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
.weekdays { flex: 0 0 auto; }
.weekdays span { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0 6px; }
.weekdays span:nth-child(6) { color: #6E82A6; }
.weekdays span:nth-child(7) { color: #B5574A; }
.cal-grid {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: repeat(6, minmax(58px, 1fr));
}

.day-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 7px 7px 5px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #FBFBF9;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.day-cell:hover { background: #F3F5F0; }
.day-cell:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

/* 날짜 칸 위 + 버튼: 올리면 나타남 */
.day-add {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--green);
  font-size: 15px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s, background-color .12s;
  z-index: 1;
}
.day-cell:hover .day-add, .day-cell:focus-within .day-add, .day-add:focus-visible { opacity: 1; }
.day-add:hover { background: var(--green); color: #fff; border-color: var(--green); }
.day-add:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.day-cell:hover .day-badges { padding-right: 22px; }
@media (hover: none) { .day-add { opacity: .55; } }
.day-cell.is-outside { opacity: .42; }
.day-cell.is-selected { background: var(--green-soft); border-color: var(--green); }
.day-cell.is-sat .day-num { color: #6E82A6; }
.day-cell.is-sun .day-num { color: #B5574A; }

.day-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 18px; }
.day-num { font-size: 13px; font-weight: 600; line-height: 1; display: inline-flex; align-items: center; gap: 4px; }
.day-cell.is-today .day-num { color: var(--green); }
.day-cell.is-today .day-num::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--today-dot);
}
.day-badges { display: flex; gap: 3px; align-items: center; font-size: 10px; color: var(--muted); line-height: 1; }
.day-badges .b-task { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px 5px; }
.day-cell.is-selected .day-badges .b-task { border-color: #CFDACF; }
.day-events { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day-ev {
  font-size: 11px; line-height: 1.35;
  padding: 1px 5px; border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: #F0EEE6; color: var(--text);
  cursor: pointer;
}
.day-ev:hover { filter: brightness(0.95); text-decoration: underline; text-decoration-color: #B9C4BB; }
.day-ev.anniversary { background: #F6E9E3; }
.day-ev.schedule { background: var(--green-soft); }
.day-cell.is-selected .day-ev.schedule { background: #DCE7DA; }
/* 여러 날짜에 걸친 일정: 왼쪽 띠 */
.day-ev.is-span { border-left: 3px solid #8FB09C; padding-left: 4px; }
.day-ev.is-span.anniversary { border-left-color: #D9A58C; }
.day-ev.is-cont { border-left-style: dotted; }
.day-more { font-size: 10px; color: var(--muted); padding-left: 4px; }

/* ---------- 오늘 한눈에 (오른쪽 칸) ---------- */
.glance-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; }
.glance-card h2 { margin-bottom: 4px; }
.glance-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: background-color .12s, border-color .12s;
}
.glance-item:hover { background: #FBFBF9; border-color: var(--line); }
.glance-item:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.glance-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-width: 0; }
.glance-label { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.glance-value { font-size: 14px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.glance-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.glance-bar { width: 100%; height: 4px; border-radius: 999px; background: var(--green-soft); overflow: hidden; }
.glance-bar > span { display: block; height: 100%; width: 0; background: var(--green); border-radius: 999px; transition: width .2s; }

/* ---------- 기념일·일정 ---------- */
.event-form {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  background: #FBFBF9;
  display: flex; flex-direction: column; gap: 10px;
}
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 120px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field input, .field select { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green); margin: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { color: var(--danger); }

input[type="text"], input[type="date"], select, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  min-height: 40px;
  background: var(--card);
  width: 100%;
  min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green);
}
textarea { resize: vertical; line-height: 1.5; }

.event-list { display: flex; flex-direction: column; gap: 6px; }
.event-item {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px;
}
.event-kind {
  flex: 0 0 auto; font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: #F6E9E3; color: #8A5A47;
}
.event-kind.schedule { background: var(--green-soft); color: var(--green); }
.event-main { flex: 1 1 120px; min-width: 0; }
.event-title { font-weight: 500; font-size: 14px; overflow-wrap: anywhere; }
.event-meta { font-size: 12px; color: var(--muted); display: flex; gap: 5px; flex-wrap: wrap; }
.event-actions { display: flex; gap: 0; flex: 0 0 auto; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

/* ---------- 일 다이어리 ---------- */
.day-bar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap; padding: 14px var(--pad);
}
.day-title { font-size: 18px; }

.note-form { display: flex; flex-direction: column; gap: 10px; }
.note-form .form-row > input { flex: 1 1 200px; }
.note-form .form-row > button { flex: 0 0 auto; }

.progress { height: 6px; background: var(--green-soft); border-radius: 999px; overflow: hidden; margin: 2px 0 12px; }
.progress-bar { height: 100%; width: 0; background: var(--green); border-radius: 999px; transition: width .2s; }

.task-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; border: 1px solid transparent;
}
.task-item:hover { background: #FBFBF9; border-color: var(--line); }
.task-item label { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.task-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--green); margin: 0; flex: 0 0 auto; }
.task-text { overflow-wrap: anywhere; }
.task-item.is-done .task-text { text-decoration: line-through; color: var(--muted); }
.badge-core { flex: 0 0 auto; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--green); color: #fff; }
.task-item .btn.link { opacity: 0; }
.task-item:hover .btn.link, .task-item:focus-within .btn.link { opacity: 1; }
@media (hover: none) { .task-item .btn.link { opacity: 1; } }

.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; }

.note-preview {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px dashed var(--line); border-radius: 12px; background: #FBFBF9;
}
.note-preview img { height: 64px; width: auto; max-width: 160px; border-radius: 8px; object-fit: cover; }
.note-img {
  display: block; max-width: 100%; max-height: 240px; width: auto;
  border-radius: 10px; margin-top: 8px; cursor: zoom-in; border: 1px solid var(--line);
  content-visibility: auto;
}
.note-img.is-large { max-height: none; cursor: zoom-out; }
.note-list { display: flex; flex-direction: column; gap: 8px; }
.note-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.note-head { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note-mood { background: var(--green-soft); color: var(--green); border-radius: 999px; padding: 1px 8px; }
.note-head .btn.link { margin-left: auto; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 프로젝트 ---------- */
.project-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.project-item { padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); }
.project-top { display: flex; align-items: center; gap: 8px; }
.project-title { font-weight: 500; font-size: 14px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.project-next {
  display: block; width: 100%; border: none; background: transparent;
  padding: 2px 0 0; min-height: 0; font-size: 13px; color: var(--muted); border-radius: 6px;
}
.project-next:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.project-next::placeholder { color: #A5AEA8; }
.side-col .inline-add input { min-height: 36px; padding: 7px 11px; }

/* ---------- 기념일·일정 팝업 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(37, 49, 44, 0.28); }
.modal-card {
  position: relative;
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 22px 18px;
  box-shadow: 0 16px 40px rgba(37, 49, 44, 0.16);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { font-size: 17px; font-weight: 600; }
.modal-close { width: 34px; min-height: 34px; font-size: 22px; color: var(--muted); }
.modal .event-form { border: none; background: transparent; padding: 0; margin: 0; gap: 12px; }
.modal .form-actions .btn { min-height: 38px; }
.modal-list { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.modal-list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal .event-item { padding: 8px 10px; }
.modal .event-item.is-editing { border-color: var(--green); background: var(--green-soft); }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--text); color: #fff; font-size: 14px;
  padding: 10px 16px; border-radius: 999px;
  max-width: calc(100vw - 32px); text-align: center;
  z-index: 50; opacity: 0; transition: opacity .15s;
}
.toast.is-visible { opacity: 1; }
.toast.is-error { background: var(--danger); }

/* ================= 일 다이어리: 예전 방식(페이지 전체 스크롤) ================= */
body.view-day .app { height: auto; min-height: 100vh; }
body.view-day .topbar {
  position: sticky; top: 0; z-index: 20;
  margin: 0 -16px; padding: 10px 18px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
body.view-day .layout { align-items: start; }
body.view-day .main-col, body.view-day .side-col { overflow: visible; min-height: auto; }
body.view-day .view { flex: 0 0 auto; gap: 18px; }
body.view-day .side-col { gap: 18px; }
body.view-day .card { padding: 22px; --pad: 22px; }
body.view-day .day-bar { padding: 16px 22px; }
body.view-day .glance-card, body.view-day .events-card { display: none; }
body.view-day .card.tint { order: -1; }

/* ================= 반응형 ================= */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; }
  .greet-sub { display: none; }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar-left { flex: 1 1 100%; }
  .topbar .tabs { order: 3; }
  .topbar-right { order: 2; margin-left: auto; }
  .layout { grid-template-columns: minmax(0, 1fr) 280px; }
}
/* 좁은 화면: 일반 문서 스크롤, 1열 */
@media (max-width: 760px) {
  .app {
    height: auto; min-height: 100vh; gap: 10px;
    padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  .topbar-right { flex: 1 1 100%; margin-left: 0; flex-wrap: wrap; }
  .logo { width: 36px; height: 36px; }
  .greet { font-size: 18px; }
  .topbar .tabs { display: flex; width: 100%; }
  .topbar .tab { flex: 1; }
  .layout { grid-template-columns: 1fr; display: flex; flex-direction: column; gap: 12px; }
  .main-col, .side-col { overflow: visible; min-height: auto; }
  .view { flex: 0 0 auto; }
  .calendar-card { flex: 0 0 auto; }
  .cal-grid { grid-template-rows: none; }
  .day-cell { height: auto; min-height: 70px; padding: 5px 4px 4px; gap: 2px; }
  .day-num { font-size: 12px; }
  .day-ev { font-size: 10px; padding: 1px 3px; }
  .day-badges { font-size: 9px; gap: 2px; }
  .day-badges .b-task { display: none; }
  .day-badges .b-task-mini { display: inline; }
  .card { padding: 16px; --pad: 16px; }
  .cal-nav .btn { min-height: 40px; }
  .cal-head { flex-wrap: wrap; }
  .cal-head > div:first-child { flex: 1 1 100%; }
  .cal-head .cal-nav { width: 100%; }
  .cal-head .cal-nav .btn.primary { flex: 1; }
  .day-bar .cal-nav { width: 100%; justify-content: space-between; }
  .day-bar .cal-nav .btn { flex: 1; }
  .card-actions { width: 100%; }
  .card-actions .btn { flex: 1; }
  .sync-panel { position: static; width: auto; box-shadow: none; }
  body.view-day .topbar { position: static; margin: 0; padding: 2px 2px 0; background: transparent; }
  body.view-day .card { padding: 16px; --pad: 16px; }
  .tabs.mini { display: inline-flex; }
  .tabs.mini .tab { flex: 0 0 auto; }
}
@media (min-width: 761px) {
  .day-badges .b-task-mini { display: none; }
}
@media (max-width: 400px) {
  .day-cell { min-height: 62px; }
  .day-ev, .day-more { display: none; }
  .day-badges .b-ev-mini { display: inline; }
}
@media (min-width: 401px) {
  .day-badges .b-ev-mini { display: none; }
}
/* 낮은 창 높이: 셀이 너무 작아지지 않게 세로 스크롤 허용 */
@media (max-height: 640px) and (min-width: 761px) {
  .cal-grid { grid-template-rows: repeat(6, minmax(64px, 1fr)); }
}
