/* 캘모니스 공통 기반: 색 변수·헤더·버튼·창·탭바. 캘린더·메모·관리 화면이 모두 먼저 불러온다(메모는 뒤에 memo.css).
   색·간격은 여기 변수 한곳에서만 정한다. 다크 모드는 변수만 바꾼다.
   기기 설정을 따르되, 버튼으로 고른 값(data-theme)이 있으면 그것이 우선한다 */
:root {
  color-scheme: light;
  --bg: #f6f7f9; --surface: #fff; --text: #1a1d26; --muted: #737a8c; --line: #eceef3;
  --primary: #3b5bdb; --primary-ink: #fff; --danger: #d6336c; --ok: #2b8a3e; --admin: #b35c00;
  --sun: #e03131; --sat: #3b5bdb; --memo: #0ca678;
  --radius: 12px; --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c; --surface: #0e1015; --text: #e9ebf2; --muted: #8e95a8; --line: #23283a;
    --primary: #7b96ff; --primary-ink: #0e1220; --danger: #ff6b9a; --ok: #69db7c; --admin: #ffa94d;
    --sun: #ff8787; --sat: #91a7ff; --memo: #20c997; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #14161c; --surface: #0e1015; --text: #e9ebf2; --muted: #8e95a8; --line: #23283a;
    --primary: #7b96ff; --primary-ink: #0e1220; --danger: #ff6b9a; --ok: #69db7c; --admin: #ffa94d;
    --sun: #ff8787; --sat: #91a7ff; --memo: #20c997; --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0 auto; padding: 0 20px 40px; max-width: 1040px; background: var(--surface); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}
body > .narrow, main.narrow { max-width: 760px; margin: 0 auto; }
h1 { font-size: 1rem; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 4px; }
h3 { font-size: .85rem; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
code { background: var(--bg); padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* 상단 */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 0 14px; }
.brand { display: flex; align-items: center; min-width: 0; }
/* 간격은 gap이 아니라 margin: 오래된 웹뷰는 flex gap을 몰라 로고와 글자가 붙는다 */
.brand img { border-radius: 7px; flex: none; width: 26px; height: 26px; margin-right: 12px; }
.brand #switch { display: flex; align-items: center; min-width: 0; color: inherit; text-decoration: none; } /* 로고·이름을 누르면 캘린더↔메모 전환 */
.actions, .tools { display: flex; align-items: center; gap: 8px; flex: none; }
.tools { flex-wrap: wrap; justify-content: flex-end; }
/* 넓은 화면: 로고 | 도구들 + 추가 버튼 한 줄. 좁은 화면(아래 미디어 쿼리)은 두 줄 */
.top { flex-wrap: wrap; }
.brand { margin-right: auto; }
.tools { order: 1; }
#add { order: 2; }
.who { color: var(--muted); font-size: .85rem; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text);
  font: inherit; font-size: .85rem; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); background: transparent; border-color: transparent; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: transparent; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 범위 전환(내 일정 | 방 일정): 메모 화면의 개인/공동 탭과 같은 모양. 두 버튼이 좁은 폭에서도 한 줄에 들어간다 */
.seg { display: flex; width: max-content; max-width: 100%; padding: 3px; border-radius: 10px; background: var(--bg); margin-bottom: 10px; }
.seg button { min-width: 72px; min-height: 32px; padding: 0 14px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
@media (pointer: coarse) { .seg button { min-height: 40px; } }

/* 범주 범례 */
.legend { display: flex; gap: 4px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; }
.legend::-webkit-scrollbar { display: none; }
.legend button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid transparent; border-radius: 999px; background: none; color: var(--muted); font: inherit; font-size: .78rem; white-space: nowrap; flex: none; cursor: pointer; }
.legend button:hover { background: var(--bg); }
.legend button[aria-pressed="true"] { border-color: var(--line); background: var(--bg); color: var(--text); font-weight: 600; }
.legend.filtering button[aria-pressed="false"] { opacity: .5; }
.legend button.reset { color: var(--primary); font-weight: 600; border-color: var(--line); position: sticky; right: 0; background: var(--surface); } /* 좁은 화면에서 범례가 옆으로 밀려도 오른쪽에 붙어 보인다 */
.legend i { width: 8px; height: 8px; border-radius: 50%; }
@media (min-width: 700px) { .legend { flex-wrap: wrap; overflow: visible; } }

/* 카드·알림 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
body:has(#cal) .card { border: 0; padding: 0; margin: 0; border-radius: 0; }
.notice { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 12px; }
.notice.bad { border-color: var(--danger); color: var(--danger); }
.notice.ok { border-color: var(--ok); color: var(--ok); }
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }

/* 입력 */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 11px; min-height: 36px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); border-color: var(--primary); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); opacity: .8; }

/* 일정 창 */
dialog {
  width: min(440px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: 16px; padding: 22px; background: var(--surface);
  color: var(--text); box-shadow: 0 16px 48px rgba(10, 12, 24, .18);
}
dialog::backdrop { background: rgba(12, 14, 24, .38); }
dialog h2 { font-size: 1.1rem; margin-bottom: 14px; }
form { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: .9rem; color: var(--text); font-weight: 500; }
label.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
label input, label select, label textarea { font-weight: 400; font-size: .95rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two input { min-width: 0; }
.btns { display: flex; gap: 8px; margin-top: 4px; }
.btns span { flex: 1; }
.meta { margin: 0; font-size: .75rem; color: var(--muted); }
.err { color: var(--danger); margin: 0; min-height: 1.2em; font-size: .85rem; }
.field { display: flex; flex-direction: column; gap: 4px; }

/* 메모 칸 @ 힌트: 입력칸 위쪽에만 뜬다(높이는 calendar.js가 위 공간에 맞춘다) */
.memo-wrap { position: relative; display: flex; flex-direction: column; }
.memo-wrap textarea { font-size: .95rem; }
.hints {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 1; margin: 0; padding: 4px; list-style: none;
  overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(10, 12, 24, .18); font-size: .9rem;
}
.hints li { padding: 8px 10px; min-height: 36px; border-radius: 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hints li:hover, .hints li[aria-selected="true"] { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.hints li.note { color: var(--muted); cursor: default; background: none; }

/* 일정 메모 속 메모 링크(칩)와 딥링크 강조 */
.chip { padding: 0 6px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 600; text-decoration: none; }
.chip:hover { text-decoration: underline; }
.chip.gone { color: var(--muted); background: var(--bg); text-decoration: line-through; }
.chip .del { display: inline-block; margin-left: 4px; font-size: .8em; text-decoration: none; } /* inline-block이라 취소선이 안 걸린다 */
.day-list li.hl { background: color-mix(in srgb, var(--primary) 10%, transparent); border-radius: 0 8px 8px 0; padding-right: 8px; }

/* 잠깐 뜨는 안내(common.js toast). 탭바 위에 뜨게 body > 로 구체성을 높였다 */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--surface); font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
body > #toast { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--ad-h, 0px) + 16px); }


/* 도움말 */
dialog.help { max-height: calc(100dvh - 32px); overflow-y: auto; word-break: keep-all; } /* 한글이 단어 중간에서 끊기지 않게 */
.help h3 { margin: 18px 0 6px; font-size: .95rem; color: var(--text); }
.help p { margin: 10px 0 4px; font-size: .9rem; }
.help ul, .help ol { margin: 0; padding-left: 20px; font-size: .9rem; }
.help li { margin: 4px 0; }
.help .meta { margin-top: 14px; }

/* 알림 */
.btn.icon { position: relative; width: 34px; padding: 0; }
#bell-dot { position: absolute; top: 5px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); box-sizing: content-box; }
dialog#notif { margin: 56px 16px auto auto; }
.n-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.n-head h2 { margin: 0; }
.n-list { list-style: none; margin: 0 0 12px; padding: 0; max-height: 55vh; overflow-y: auto; }
.n-list li { padding: 10px 0 10px 14px; border-bottom: 1px solid var(--line); position: relative; font-size: .9rem; }
.n-list li.unread { font-weight: 600; }
.n-list li.unread::before { content: ""; position: absolute; left: 0; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.n-list li.empty { border: 0; padding-left: 0; color: var(--muted); }
.n-list .meta { font-weight: 400; }
.n-list li.go { cursor: pointer; }
.n-list li.go:hover { background: var(--bg); }

/* 선택한 날짜의 일정 목록(달력 아래 섹션) */
.day-panel { margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--line); }
.day-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.day-head h2 { margin: 0; }
.day-head .hol-name { color: var(--sun); font-weight: 600; }
.fc .fc-daygrid-day.sel { box-shadow: inset 0 0 0 2px var(--primary); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.day-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.day-list li { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.day-list li p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.day-list li.empty { border-left: 0; padding-left: 0; color: var(--muted); }

/* FullCalendar */
.fc {
  --fc-border-color: var(--line); --fc-page-bg-color: transparent; --fc-neutral-bg-color: transparent;
  --fc-today-bg-color: transparent;
  --fc-button-bg-color: var(--surface); --fc-button-border-color: var(--line); --fc-button-text-color: var(--text);
  --fc-button-hover-bg-color: var(--bg); --fc-button-hover-border-color: var(--muted);
  --fc-button-active-bg-color: var(--bg); --fc-button-active-border-color: var(--muted);
  --fc-more-link-bg-color: transparent; --fc-more-link-text-color: var(--muted);
}
.fc .fc-toolbar { gap: 8px; margin-bottom: 14px !important; }
.fc .fc-toolbar-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.fc .fc-button { border-radius: 8px; font-weight: 600; font-size: .82rem; box-shadow: none !important; padding: .4em .8em; }
.fc .fc-button-group > .fc-button { border-radius: 0; }
.fc .fc-button-group > .fc-button:first-child { border-radius: 8px 0 0 8px; }
.fc .fc-button-group > .fc-button:last-child { border-radius: 0 8px 8px 0; }
.fc .fc-scrollgrid { border: 0; }
.fc .fc-scrollgrid td:last-child, .fc .fc-scrollgrid th:last-child { border-right: 0; }
.fc .fc-scrollgrid-section > td, .fc .fc-daygrid-day { border-left: 0; border-right: 0; } /* 세로선은 빼고 가로선만 */
.fc .fc-col-header-cell { border-left: 0; border-right: 0; padding: 8px 0; }
.fc .fc-col-header-cell-cushion { font-size: .78rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.fc .fc-col-header-cell.fc-day-sun .fc-col-header-cell-cushion { color: var(--sun); }
.fc .fc-col-header-cell.fc-day-sat .fc-col-header-cell-cushion { color: var(--sat); }
.fc .fc-daygrid-day-number { font-size: .82rem; padding: 4px 6px; text-decoration: none; color: var(--text); }
.fc .fc-day-sun .fc-daygrid-day-number, .fc td.holiday:not(.fc-day-today) .fc-daygrid-day-number { color: var(--sun); }
.fc .fc-day-sat .fc-daygrid-day-number { color: var(--sat); }
.fc .fc-day-other .fc-daygrid-day-top { opacity: .38; }
.fc .fc-day-today .fc-daygrid-day-number {
  background: var(--primary); color: var(--primary-ink); border-radius: 999px; min-width: 26px; text-align: center;
  margin: 3px; padding: 1px 6px; font-weight: 700;
}
.fc .fc-daygrid-day:hover { background: color-mix(in srgb, var(--text) 3%, transparent); cursor: pointer; }
.fc .fc-event { border-radius: 4px; border-width: 0 0 0 3px; font-size: .75rem; font-weight: 500; cursor: pointer; }
.fc .fc-daygrid-event { padding: 1px 5px; margin: 1px 4px; }
.fc .fc-daygrid-dot-event { background: transparent; }
.fc .fc-daygrid-dot-event:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.fc .fc-event-title { font-weight: 500; }
.fc .fc-daygrid-more-link { font-size: .72rem; font-weight: 600; margin: 0 6px; }

/* 좁은 화면 */
@media (max-width: 560px) {
  body { padding: 0 10px 24px; }
  .top { padding: 14px 0 10px; row-gap: 8px; }
  .top { gap: 8px; } .head-actions { gap: 4px; } #add { padding: 0 12px; }
  .brand img { margin-right: 8px; } /* 360dp 폭에서도 헤더가 한 줄 */
  .tools { order: 3; flex: 1 0 100%; gap: 6px; }
  .tools .btn:not(.icon) { padding: 0 10px; }
  .who { display: none; } /* 둘째 줄에 아이콘이 7개까지 늘어나 자리가 모자란다 */
  .card { padding: 6px; border-radius: 12px; }
  .fc .fc-toolbar-title { font-size: 1rem; }
  .fc .fc-button { padding: .35em .6em; }
  .fc .fc-daygrid-day-number { padding: 2px 4px; font-size: .75rem; }
  .fc .fc-event { font-size: .68rem; }
  .two { grid-template-columns: 1fr; }
  dialog { padding: 18px; }
}

/* 터치 기기: 누르는 곳은 44px 이상 */
@media (pointer: coarse) {
  body .btn { min-height: 44px; }
  body .btn.icon { width: 44px; }
  .legend button { min-height: 36px; }
}

/* 방 칩과 방 다이얼로그 */
#room-btn { max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-list { list-style: none; margin: 0; padding: 0; }
.room-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 10px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.room-item:hover:not(:disabled) { border-color: var(--muted); }
.room-item:disabled { cursor: default; border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); }
.room-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.room-now { font-size: .72rem; color: var(--primary); }
.room-row { display: flex; align-items: center; gap: 8px; }
.room-row input { flex: 1; min-width: 0; }
.room-code { flex: 1; font-size: 1.9rem; font-weight: 700; letter-spacing: .3em; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Consolas, monospace; user-select: all; }
.room-dlg { max-height: calc(100dvh - 32px); overflow-y: auto; word-break: keep-all; }
.room-dlg h3 { margin: 18px 0 8px; }
.room-join { display: flex; flex-direction: column; gap: 6px; }

/* 로그인 화면 */
.login { max-width: 360px; margin: 0 auto; padding: 12vh 0 40px; text-align: center; }
.login img { border-radius: 14px; }
.login h1 { margin: 12px 0 6px; }
.login .hint { margin-bottom: 24px; word-break: keep-all; }
.login-btns { display: flex; flex-direction: column; gap: 10px; }
.login-btn { display: flex; align-items: center; justify-content: center; min-height: 46px; font-weight: 600; text-decoration: none; }
.login-btn.google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.login-btn.kakao { background: #fee500; color: #191919; border-color: #fee500; }
.login-btn.naver { background: #03c75a; color: #fff; border-color: #03c75a; }
.login-dev { margin-top: 28px; text-align: left; font-size: .75rem; }
.login-dev input { font-size: .85rem; }

/* 좌상단 'Calmonis': 지금 보는 쪽(캘린더=Cal, 메모=mo)만 강조한다 */
.wordmark { white-space: nowrap; font-weight: 500; letter-spacing: 0; }
.wordmark span { color: var(--muted); }
.wordmark span.on { color: var(--primary); font-weight: 800; font-size: 1.15em; }
.wordmark-memo span.on { color: var(--memo); } /* 메모 로고의 초록 */

/* 하단 배너 광고(앱 전용): 배너는 WebView 위에 겹쳐 그려져서, 앱이 알려 주는 높이(--ad-h)만큼 아래를 비운다 */
html { padding-bottom: var(--ad-h, 0px); }

/* 메뉴 서랍: 상단 버튼들을 오른쪽에서 밀려 나오는 창으로 모았다 */
.head-actions { display: flex; align-items: center; gap: 8px; flex: none; order: 1; }
dialog.menu { position: fixed; top: 0; right: 0; bottom: 0; left: auto; margin: 0; width: 320px; max-width: 86vw; height: 100vh; height: 100dvh; max-height: none; border: 0;
  border-left: 1px solid var(--line); border-radius: 0; background: var(--surface); color: var(--text); padding: 0; }
dialog.menu::backdrop { background: rgba(0, 0, 0, .4); }
.menu-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 16px 8px; }
.menu-head .who { display: block; max-width: 11em; font-size: .95rem; color: var(--text); font-weight: 600; }
.menu-list { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px)); }
.menu-list .btn { width: 100%; min-height: 44px; justify-content: flex-start; gap: 10px; padding: 0 12px; }
.menu-list .btn.icon { width: 100%; padding: 0 12px; }
.menu-list .btn[hidden] { display: none; }
.menu-list #room-btn { max-width: none; width: 100%; }

.support-actions { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.support-actions .btn { min-height: 44px; }

.help-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); }

/* 도움말: 구역을 접어 두고 필요한 것만 펼친다 */
.help details.sec { border-top: 1px solid var(--line); }
.help details.sec:first-of-type { margin-top: 8px; }
.help details.sec > summary { cursor: pointer; list-style: none; padding: 12px 2px; font-size: .95rem; font-weight: 700; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.help details.sec > summary::-webkit-details-marker { display: none; }
.help details.sec > summary::after { content: ""; width: 8px; height: 8px; margin-right: 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; flex: none; }
.help details.sec[open] > summary::after { transform: rotate(-135deg); }
.help details.sec > :not(summary) { margin-left: 2px; margin-right: 2px; }
.help details.sec[open] { padding-bottom: 10px; }
.brand .switch-arrow { flex: none; margin-left: 6px; color: var(--muted); }
@media (max-width: 560px) { /* 360dp: 로고 옆 화살표가 들어가도 헤더가 한 줄. 위쪽 규칙의 gap은 뒤의 .head-actions 규칙에 덮여 여기서 다시 지정한다 */
  .top { gap: 6px; } .head-actions { gap: 4px; } .brand img { margin-right: 6px; } .brand .switch-arrow { width: 12px; height: 12px; margin-left: 4px; }
}
