/* 채움 일정. 색은 뜻 넷(브랜드·성공·주의·실패)과 회색 단계만 쓴다(ui_ux_style §1.4). */
:root {
  --brand: #2f6bd8; --brand-strong: #2358b8; --brand-soft: #e9f0fc; --brand-ink: #1f4f9f;
  --ok: #1f8a4c; --ok-soft: #e6f5ec;
  --warn: #9a6a12; --warn-soft: #fbf1dc;
  --bad: #c43d3d; --bad-soft: #fcebeb;
  --ink: #1f2937; --muted: #64748b; --faint: #94a3b8;
  --line: #e2e8f0; --line-soft: #eef2f6; --bg: #f6f8fb; --face: #ffffff; --hover: #f1f5f9;
  --font: Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --side: 220px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: 6px 12px; background: none; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.primary { background: var(--brand); color: #fff; font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--brand-strong); }
.soft { background: var(--face); border-color: var(--line); }
.soft:hover:not(:disabled) { background: var(--hover); }
.danger-soft { background: var(--bad-soft); color: var(--bad); }
.link { color: var(--brand-ink); padding: 2px 4px; }
.link:hover:not(:disabled) { text-decoration: underline; }
a.link { text-decoration: none; font-size: 13px; }
.icon { width: 32px; padding: 4px 0; font-size: 20px; line-height: 1; color: var(--muted); }
.icon:hover { background: var(--hover); }
.small { padding: 3px 10px; font-size: 13px; }

/* 머리 줄 */
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px; flex-wrap: wrap; }
.nav { display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1 1 auto; }
.nav h1 { font-size: 18px; font-weight: 700; margin: 0 0 0 8px; white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; background: var(--line-soft); border-radius: 9px; padding: 2px; }
.tabs button { padding: 4px 14px; border-radius: 7px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--face); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
/* 상태 칸: 제목 오른쪽 끝(바뀌는 글자는 끝에 둔다). 첫 응답「불러오는 중」과 오류·다시 불러오기가 이 자리에 온다 */
.status { flex: 0 1 auto; min-width: 0; margin-left: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status.bad { color: var(--bad); }
.status .link { font-size: 13px; }

.layout { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--side); gap: 12px; padding: 0 16px 16px; }
.view { min-height: 0; min-width: 0; background: var(--face); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.side { display: flex; flex-direction: column; gap: 8px; }
.side h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 0; }
.side-btns { display: flex; flex-direction: column; gap: 6px; }
.side-btns button { text-align: left; }
.side-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.note { margin: 0; font-size: 12px; color: var(--muted); }
.side-msg { min-height: 40px; margin: 0; font-size: 13px; color: var(--muted); }
.side-msg.bad { color: var(--bad); }
.who { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }

.d0 { color: var(--bad); }   /* 일요일 빨강: 달력의 관습(쉬는 날). 상태색과 뜻이 겹치지만 한국 달력 읽기에 맞춤 */
.ai { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 5px; font-size: 11px; font-weight: 600; line-height: 16px; color: var(--muted); border: 1px solid var(--faint); background: var(--face); flex: none; }

/* 일정 조각 */
.chip { display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0; padding: 1px 6px; border-radius: 5px; border: 0; border-left: 3px solid var(--brand); background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; line-height: 18px; text-align: left; }
.chip:hover { background: #dde8fb; }
.chip.allday { background: var(--brand); color: #fff; border-left-color: var(--brand-strong); }
.chip.allday:hover { background: var(--brand-strong); }
.chip .t { flex: none; font-variant-numeric: tabular-nums; opacity: .85; }
.chip .s { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* 월 */
.month { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.m-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.dow { padding: 6px 8px; font-size: 12px; color: var(--muted); }
.dow.d0 { color: var(--bad); }
.m-grid { flex: 1 1 auto; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(6, minmax(92px, 1fr)); min-height: 0; }
.m-cell { border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); padding: 2px 3px 4px; min-width: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.m-cell:nth-child(7n) { border-right: 0; }
.m-cell:hover { background: #fafbfd; }
.m-cell.out .num { color: var(--faint); }
.m-cell .num { align-self: flex-start; padding: 0; width: 26px; height: 24px; border-radius: 13px; font-size: 13px; font-variant-numeric: tabular-nums; }
.m-cell .num:hover { background: var(--hover); }
.m-cell.today .num { background: var(--brand); color: #fff; font-weight: 600; }
.m-items { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.more { align-self: flex-start; padding: 0 6px; font-size: 12px; color: var(--muted); border-radius: 5px; }
.more:hover { background: var(--hover); }

/* 주 */
/* 주 보기는 .week 하나가 가로·세로로 구른다. 머리(요일·종일)는 위에, 시각 칸은 왼쪽에 붙어 있다 */
.week { flex: 1 1 auto; min-height: 0; overflow: auto; }
.wk-inner { min-width: 620px; }
.wk-top { position: sticky; top: 0; z-index: 5; background: var(--face); }
.wk-row { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); }
.wk-head { border-bottom: 1px solid var(--line); }
.wk-gut { font-size: 11px; color: var(--faint); text-align: right; padding: 4px 6px 0 0; position: sticky; left: 0; z-index: 3; background: var(--face); }
.wk-day { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 6px 0; border-radius: 0; color: var(--muted); }
.wk-day:hover { background: var(--hover); }
.wk-day .dn { font-size: 16px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.wk-day.d0 .dn { color: var(--bad); }
.wk-day.today .dn { color: #fff; background: var(--brand); border-radius: 13px; padding: 0 7px; }
.wk-allday { border-bottom: 1px solid var(--line); min-height: 28px; }
.wk-adcell { border-left: 1px solid var(--line-soft); padding: 2px; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.wk-hours .hr { height: 44px; transform: translateY(-7px); }
.wk-col { position: relative; border-left: 1px solid var(--line-soft); background-image: repeating-linear-gradient(to bottom, var(--line-soft) 0 1px, transparent 1px 44px); cursor: pointer; }
.wk-col.today { background-color: #fbfcff; }
.wk-ev { position: absolute; align-items: flex-start; flex-direction: column; gap: 0; overflow: hidden; padding: 2px 5px; font-size: 12px; }
.wk-ev .t { font-size: 11px; }
.wk-ev .s { white-space: normal; }
.wk-ev .ai { position: absolute; right: 3px; top: 2px; }
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--brand); pointer-events: none; }

/* 목록 */
.list { overflow-y: auto; padding: 4px 0 12px; flex: 1 1 auto; }
.l-day { padding: 8px 16px 4px; max-width: 880px; }
.l-date { font-size: 13px; font-weight: 600; color: var(--muted); margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.l-day.today .l-date { color: var(--brand-ink); }
.l-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) minmax(0, 220px); gap: 12px; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; border-left: 3px solid var(--brand); background: var(--face); margin-bottom: 4px; }
.l-row:hover { background: var(--hover); }
.l-when { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.l-title { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-loc { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 24px 16px; margin: 0; }

.login { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 16px; }
.login-msg { min-height: 20px; margin: 0; color: var(--muted); font-size: 13px; }

/* 일정 창 */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 24px)); color: var(--ink); box-shadow: 0 12px 40px rgba(15, 23, 42, .14); }
dialog::backdrop { background: rgba(15, 23, 42, .25); }
dialog form { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 16px; }
dialog h2 { font-size: 16px; margin: 0 0 2px; }
dialog label { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 8px; }
dialog label > span, .lab { font-size: 13px; color: var(--muted); }
dialog input:not([type=checkbox]), dialog select, dialog textarea { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: var(--face); min-width: 0; }
dialog input:disabled { color: var(--faint); background: var(--bg); }
dialog textarea { resize: vertical; }
.f-title input { font-size: 15px; }
dialog .f-check { display: flex; gap: 6px; margin-left: 52px; font-size: 13px; }
.f-when { display: grid; grid-template-columns: 44px minmax(0, 1fr) 136px; gap: 6px 8px; align-items: center; }
.f-when .lab:nth-of-type(2) { grid-column: 1; }
.meta-row, .err-row { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.meta { margin: 0; flex: 1 1 auto; font-size: 13px; color: var(--muted); }
.err { margin: 0; flex: 1 1 auto; font-size: 13px; color: var(--bad); }
.foot { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1 1 auto; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 0); display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 10px; background: #26303d; color: #fff; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .15s; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; pointer-events: auto; }
.toast button { color: #a9c6ff; font-weight: 600; padding: 2px 6px; }

/* 좁은 폭(메신저 오른쪽 칸, 휴대폰): 연동 칸은 아래로 */
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; padding: 0 8px 8px; gap: 8px; }
  .bar { padding: 8px 8px 8px; gap: 8px; }
  .week { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .week.end { -webkit-mask-image: none; mask-image: none; }
  .l-row { padding: 6px 8px; gap: 2px 10px; }
  .side { gap: 4px; }
  .side h2 { display: none; }
  .side-btns { flex-direction: row; overflow-x: auto; gap: 6px; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); padding-right: 24px; }
  .side-btns button { flex: none; }
  .side-msg { min-height: 18px; }
  .who { margin-top: 0; }
  .nav h1 { font-size: 16px; margin-left: 4px; }
  .nav { flex-basis: 100%; }
  .tabs { margin-right: auto; }
  .m-grid { grid-template-rows: repeat(6, minmax(64px, 1fr)); }
  .m-cell { padding: 1px 1px 2px; }
  .chip { padding: 0 3px; font-size: 11px; line-height: 16px; border-left-width: 2px; }
  .m-cell .chip .t { display: none; }
  .m-cell .chip .ai { display: none; }
  .l-row { grid-template-columns: 96px minmax(0, 1fr); }
  .l-loc { grid-column: 2; }
  .l-day { padding: 6px 8px 2px; }
}
