/* 카피에스스토리 그룹웨어 - 전역 스타일 (설계서 디자인 토큰 계승) */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: light;
  --bg: #FAFAF7;
  --bg-raised: #FFFFFF;
  --bg-sunken: #F1EFE6;
  --ink: #1C1B19;
  --ink-soft: #4A4740;
  --muted: #6B6858;
  --line: #E4E1D8;
  --line-strong: #CFCBBC;
  --accent: #2B5D4F;
  --accent-soft: #E4EEE9;
  --accent-ink: #16342B;
  --warn: #B5482A;
  --warn-soft: #F5E6DF;
  --future: #8B7E5A;
  --future-soft: #F1EAD3;
  --stub: #706C88;
  --stub-soft: #EAE8F1;
  --shadow: 0 1px 2px rgba(28,27,25,0.04), 0 4px 16px rgba(28,27,25,0.05);
  /* accent/warn 색상칠 배경(버튼, 선택칩, 채팅 말풍선 등) 위에 올리는 글자색.
     라이트모드는 accent/warn이 어두운 색이라 흰 글자가 맞지만, 다크모드는 두 색이 밝아지므로
     흰 글자를 그대로 쓰면 대비가 거의 없어 읽기 어려워진다 - 다크모드 가독성 문제의 핵심 원인 */
  --accent-on: #FFFFFF;
  --warn-on: #FFFFFF;
  --mini-badge-bg: rgba(0,0,0,0.08);
  --mini-badge-bg-soft: rgba(0,0,0,0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #17181A; --bg-raised: #1F2023; --bg-sunken: #131416;
    --ink: #EDEBE3; --ink-soft: #C7C4B8; --muted: #948F80;
    --line: #333430; --line-strong: #45463F;
    --accent: #6FBFA3; --accent-soft: #1D2F29; --accent-ink: #A9E0CC;
    --warn: #E08A6B; --warn-soft: #34241E;
    --future: #D4C48F; --future-soft: #322C1C;
    --stub: #B0A9D6; --stub-soft: #26243A;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.35);
    --accent-on: #0F2620; --warn-on: #351909;
    --mini-badge-bg: rgba(255,255,255,0.16); --mini-badge-bg-soft: rgba(255,255,255,0.1);
  }
}

/* 명시적 다크모드 토글용 (향후 수동 전환 대비) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17181A; --bg-raised: #1F2023; --bg-sunken: #131416;
  --ink: #EDEBE3; --ink-soft: #C7C4B8; --muted: #948F80;
  --line: #333430; --line-strong: #45463F;
  --accent: #6FBFA3; --accent-soft: #1D2F29; --accent-ink: #A9E0CC;
  --warn: #E08A6B; --warn-soft: #34241E;
  --future: #D4C48F; --future-soft: #322C1C;
  --stub: #B0A9D6; --stub-soft: #26243A;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.35);
  --accent-on: #0F2620; --warn-on: #351909;
  --mini-badge-bg: rgba(255,255,255,0.16); --mini-badge-bg-soft: rgba(255,255,255,0.1);
}

* { box-sizing: border-box; }
:root { --font-scale: 1; } /* 환경설정 글자 크기 배율. html의 font-size를 조정해 앱 전체 rem 단위 텍스트에 일괄 반영됨 */
html { font-size: calc(16px * var(--font-scale)); }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-ui);
  margin: 0; padding: 0; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s, color 0.15s;
  font-size: 0.9375rem; /* 기존 대비 소폭 상향된 기본 본문 크기 */
}
h1, h2, h3, h4 { font-family: var(--font-ui); color: var(--ink); margin: 0; }
button, input, select, textarea { font-family: var(--font-ui); font-size: 0.92rem; }
a { color: inherit; }
code, .mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

/* ---------- 로그인 페이지 ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 40px 36px; width: 100%; max-width: 380px; }
.login-brand { font-family: var(--font-ui); font-weight: 700; font-size: 1.4rem; text-align: center; margin-bottom: 28px; }
.login-brand span { display: block; font-size: 0.75rem; font-weight: 500; color: var(--muted); margin-top: 4px; }
.login-field { margin-bottom: 14px; }
.login-field input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-error { background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: 8px; font-size: 0.8rem; margin-bottom: 14px; }
.btn-block { width: 100%; }

/* ---------- 앱 셸 레이아웃 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 224px; flex-shrink: 0; background: var(--bg-raised); border-right: 1px solid var(--line); padding: 24px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { font-family: var(--font-ui); font-weight: 700; font-size: 1rem; padding: 0 10px; margin-bottom: 24px; }
.sidebar-brand-sub { display: block; font-size: 0.68rem; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* 다크/라이트 테마 전환 버튼 (사이드바 브랜드와 메뉴 사이) */
.theme-toggle { display: flex; align-items: center; gap: 4px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.theme-toggle-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 7px 4px; border-radius: 7px; border: none; background: transparent; color: var(--muted); font-size: 0.68rem; font-weight: 550; cursor: pointer; transition: background-color 0.15s, color 0.15s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-toggle-btn:hover { color: var(--ink-soft); }
.theme-toggle-btn.active { background: var(--bg-raised); color: var(--ink); box-shadow: var(--shadow); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--ink-soft); font-size: 0.9rem; font-weight: 500; }
.nav-link:hover { background: var(--bg-sunken); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 550; }
.nav-icon { font-size: 1.05rem; width: 20px; text-align: center; }

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: flex-end; padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--bg-raised); position: sticky; top: 0; z-index: 10; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.notif-bell { position: relative; background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 6px; border-radius: 8px; }
.notif-bell:hover { background: var(--bg-sunken); }
.notif-count { position: absolute; top: -2px; right: -2px; background: var(--warn); color: var(--warn-on); font-size: 0.62rem; font-weight: 600; padding: 1px 5px; border-radius: 10px; font-family: var(--font-ui); }
.user-badge { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.82rem; }
.user-name { font-weight: 550; font-family: var(--font-ui); }
.user-dept { color: var(--muted); font-size: 0.74rem; }
.page-content { padding: 24px 28px 60px; flex: 1; }

.notif-panel { position: absolute; top: 60px; right: 28px; width: 340px; max-height: 420px; overflow-y: auto; background: var(--bg-raised); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 100; padding: 10px; }
.notif-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.notif-item { padding: 10px; border-radius: 8px; cursor: pointer; }
.notif-item:hover { background: var(--bg-sunken); }
.notif-item.unread { background: var(--accent-soft); }
.notif-title { font-weight: 550; font-size: 0.8rem; }
.notif-body { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 0.65rem; color: var(--muted); margin-top: 4px; font-family: 'IBM Plex Mono', monospace; }
.notif-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 0.8rem; }

/* ---------- 알림함 (좌측 메뉴 전용 페이지) ---------- */
.noti-inbox-list { display: flex; flex-direction: column; gap: 6px; max-width: 720px; }
.noti-inbox-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-raised); cursor: pointer; }
.noti-inbox-item:hover { border-color: var(--line-strong); }
.noti-inbox-item.unread { background: var(--accent-soft); border-color: var(--accent-soft); }
.noti-inbox-main { flex: 1; min-width: 0; }
.noti-inbox-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; margin-top: 5px; }

/* ---------- 공통 위젯 ---------- */
.btn { font-family: var(--font-ui); font-weight: 550; font-size: 0.8rem; padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer; transition: opacity 0.15s; }
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-on); }
.btn-ghost { background: var(--bg-sunken); color: var(--ink-soft); border: 1px solid var(--line); }
.btn-danger { background: var(--warn); color: var(--warn-on); }
.btn-sm { padding: 6px 12px; font-size: 0.72rem; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { font-size: 1.4rem; font-weight: 600; }
.toolbar { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar select, .toolbar input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-raised); color: var(--ink); font-size: 0.88rem; }
/* 드롭다운 필터에 이름 라벨을 붙여 어떤 필터인지 바로 알 수 있게 함 */
.toolbar-field { display: flex; flex-direction: column; gap: 4px; }
.toolbar-field-label { font-size: 0.7rem; font-weight: 550; color: var(--muted); padding-left: 2px; }

table.data-table { width: 100%; border-collapse: collapse; background: var(--bg-raised); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
table.data-table th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 550; padding: 10px 14px; border-bottom: 1px solid var(--line-strong); background: var(--bg-sunken); cursor: pointer; user-select: none; }
table.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 0.9rem; color: var(--ink-soft); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr.clickable { cursor: pointer; }
table.data-table tr.clickable:hover { background: var(--bg-sunken); }

.badge { display: inline-block; font-size: 0.76rem; font-weight: 550; padding: 3px 9px; border-radius: 20px; font-family: var(--font-ui); }
.badge-default { background: var(--bg-sunken); color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-future { background: var(--future-soft); color: var(--future); }
.badge-stub { background: var(--stub-soft); color: var(--stub); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.spinner-box { display: flex; justify-content: center; padding: 40px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { padding: 40px; text-align: center; color: var(--warn); }

/* ---------- 모달 ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal { background: var(--bg-raised); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-raised); }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 22px; }

/* ---------- 폼 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 0.72rem; font-weight: 550; color: var(--muted); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--ink); font-size: 0.82rem;
  color-scheme: inherit;
}
.form-field textarea { resize: vertical; min-height: 80px; font-family: var(--font-ui); }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
/* 날짜/시간 입력 - 다크모드에서 캘린더/시계 아이콘이 배경에 묻히지 않도록 명시 처리 */
.form-field input[type="date"], .form-field input[type="datetime-local"], .form-field input[type="time"],
.toolbar input[type="date"], .toolbar input[type="datetime-local"], .toolbar input[type="time"] {
  color-scheme: inherit;
  cursor: text;
}
.form-field input[type="date"]::-webkit-calendar-picker-indicator,
.form-field input[type="datetime-local"]::-webkit-calendar-picker-indicator,
.form-field input[type="time"]::-webkit-calendar-picker-indicator,
.toolbar input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  border-radius: 4px;
  padding: 3px;
  opacity: 0.85;
}
.form-field input[type="date"]::-webkit-calendar-picker-indicator:hover,
.form-field input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
.form-field input[type="time"]::-webkit-calendar-picker-indicator:hover,
.toolbar input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background: var(--bg-sunken);
}
/* 커스텀 select 화살표 - 브라우저 기본 아이콘이 배경과 충돌하지 않도록 직접 그림 */
.form-field select, .toolbar select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236B6858' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.multi-select-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-select { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--line); font-size: 0.75rem; cursor: pointer; background: var(--bg); }
.chip-select.selected { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }

/* ---------- 토스트 ---------- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 8px; font-size: 0.82rem; opacity: 0; transform: translateY(10px); transition: all 0.25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--warn); }
.toast-success { background: var(--accent); }

/* ---------- 대시보드 ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.dash-card { background: var(--bg-raised); border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); }
.dash-card h4 { font-size: 0.82rem; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.dash-num { font-family: 'IBM Plex Mono', monospace; font-size: 1.9rem; font-weight: 550; }
.dash-section { margin-bottom: 28px; }
.dash-section h3 { font-size: 1.08rem; margin-bottom: 12px; }
.dash-section-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.dash-section-head h3 { margin-bottom: 0; }

/* 클릭 가능한 대시보드 카드/숫자/텍스트 - 윤곽을 명확히 강조 */
.dash-card.clickable, .dash-num.clickable, .clickable-text {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, color 0.15s;
}
.dash-card.clickable { border-color: var(--accent); }
.dash-card.clickable:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); transform: translateY(-1px); }
.dash-card.clickable:active { transform: translateY(0); }
.dash-num.clickable { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-soft); text-underline-offset: 4px; }
.dash-num.clickable:hover { text-decoration-color: var(--accent); }
.clickable-text { color: var(--accent-ink); border-bottom: 1.5px solid var(--accent-soft); }
.clickable-text:hover { border-bottom-color: var(--accent); }

/* ---------- 칸반 ---------- */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; align-items: start; }
.kanban-col { background: var(--bg-sunken); border-radius: 10px; padding: 12px; min-height: 200px; }
.kanban-col-head { font-family: var(--font-ui); font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; padding: 0 4px; display: flex; justify-content: space-between; }
.kanban-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; }
.kanban-card:hover { border-color: var(--line-strong); }
.kanban-card-title { font-weight: 550; font-size: 0.82rem; margin-bottom: 6px; }
.kanban-card-meta { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--muted); }

/* ---------- 상세 페이지 (자유노트/댓글) ---------- */
.detail-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .detail-layout { grid-template-columns: 1fr; } }
.detail-panel { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.detail-panel h3 { font-size: 0.95rem; margin-bottom: 14px; }
.note-block { padding: 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; background: var(--bg-sunken); }
.note-block-meta { font-size: 0.68rem; color: var(--muted); margin-bottom: 6px; font-family: 'IBM Plex Mono', monospace; }
.comment-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment-item:last-child { border-bottom: none; }
.comment-meta { font-size: 0.7rem; color: var(--muted); margin-bottom: 4px; }
.comment-actions { display: flex; gap: 8px; margin-top: 6px; }
.comment-actions button { background: none; border: none; color: var(--muted); font-size: 0.68rem; cursor: pointer; text-decoration: underline; padding: 0; }

/* 댓글/자유노트 내용 서식 (마크다운 변환 결과물에 적용) */
.rich-content { white-space: normal; line-height: 1.6; word-break: break-word; }
.rich-content code { background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 0.85em; }
.rich-content .md-list { margin: 4px 0; padding-left: 20px; }
.rich-content a { color: var(--accent-ink); text-decoration: underline; }
.mention-tag { color: var(--accent-ink); background: var(--accent-soft); border-radius: 4px; padding: 0 3px; font-weight: 550; }
/* 업무/프로젝트 멘션은 실제로 클릭해서 이동할 수 있는 링크이므로 밑줄과 포인터 커서로 구분한다 */
a.mention-link { text-decoration: underline; cursor: pointer; }
/* 날짜 멘션은 사람/업무 멘션과 시각적으로 구분되도록 다른 색조를 쓴다 */
.mention-tag.mention-date { color: var(--ink); background: var(--bg-sunken); }

/* 댓글/자유노트 입력창 - TOAST UI Editor(client/vendor/toastui-editor.js) 기반 실시간 서식 편집기 +
   자체 구현한 @멘션 자동완성 드롭다운(사람/날짜/업무/프로젝트 섹션 표시) */
.mention-input-wrap { margin-bottom: 10px; }
.mention-input-hint { font-size: 0.68rem; color: var(--muted); margin-top: 4px; }
.mention-dropdown { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; max-height: 260px; overflow-y: auto; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); z-index: 20; }
.mention-dropdown-section { padding: 6px 12px 2px; font-size: 0.68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em; }
.mention-dropdown-item { padding: 8px 12px; font-size: 0.82rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-dropdown-item:hover, .mention-dropdown-item.active { background: var(--accent-soft); color: var(--accent-ink); }

/* TOAST UI Editor 컨테이너 - 라이브러리 자체 스타일(vendor/toastui-editor.css)을 기본으로 쓰고
   그룹웨어 전체 폰트/모서리 둥글기와 자연스럽게 어울리도록 최소한만 덮어쓴다 */
.toastui-editor-host { border-radius: 8px; overflow: hidden; }
.toastui-editor-host .tui-editor-defaultUI { border: 1px solid var(--line); border-radius: 8px; }
.toastui-editor-host .te-editor-section, .toastui-editor-host .tui-editor-contents { font-family: var(--font-ui); font-size: 0.85rem; }

/* ---------- 채팅 ---------- */
.chat-layout { display: grid; grid-template-columns: 260px 1fr; gap: 0; height: calc(100vh - 140px); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-raised); }
.chat-room-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-room-item { padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat-room-item:hover { background: var(--bg-sunken); }
.chat-room-item.active { background: var(--accent-soft); }
.chat-room-name { font-weight: 550; font-size: 0.85rem; }
.chat-room-preview { font-size: 0.72rem; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { display: flex; gap: 8px; max-width: 70%; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-bubble { background: var(--bg-sunken); padding: 9px 13px; border-radius: 12px; font-size: 0.82rem; }
.chat-msg.mine .chat-bubble { background: var(--accent); color: var(--accent-on); }
.chat-msg-name { font-size: 0.65rem; color: var(--muted); margin-bottom: 3px; }
.chat-input-bar { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input-bar input[type=text] { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }

/* ---------- 통합 스케줄러 ---------- */
.schedule-page { display: flex; flex-direction: column; min-height: calc(100vh - 140px); }
.sched-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sched-toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sched-nav { display: flex; align-items: center; gap: 6px; }
.sched-nav-label { font-weight: 600; font-size: 1.05rem; min-width: 120px; text-align: center; }

.view-tabs { display: flex; gap: 3px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.view-tab { border: none; background: transparent; padding: 7px 16px; border-radius: 6px; font-size: 0.78rem; font-weight: 550; color: var(--muted); cursor: pointer; }
.view-tab.active { background: var(--bg-raised); color: var(--accent-ink); box-shadow: var(--shadow); }

.sched-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sched-filter-label { font-size: 0.74rem; font-weight: 550; color: var(--muted); margin-right: 2px; }
.sched-staff-select { width: auto; min-width: 130px; margin-left: 6px; padding: 5px 10px; font-size: 0.78rem; border-radius: 20px; }
.filter-chip { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--bg-raised); border-radius: 20px; padding: 5px 12px; font-size: 0.76rem; font-weight: 550; cursor: pointer; color: var(--muted); }
.filter-chip.active { border-color: currentColor; }
.filter-chip-all-btn { border: 1px solid var(--line); background: var(--bg-sunken); border-radius: 20px; padding: 5px 12px; font-size: 0.72rem; font-weight: 550; cursor: pointer; color: var(--ink-soft); }
.filter-chip-all-btn:hover { background: var(--bg-raised); border-color: var(--line-strong); }

.sched-legend { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 10px 14px; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; font-size: 0.74rem; color: var(--ink-soft); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: currentColor; }
.legend-dot.badge-default { background: var(--muted); }
.legend-dot.badge-accent { background: var(--accent); }
.legend-dot.badge-warn { background: var(--warn); }
.legend-dot.badge-future { background: var(--future); }
.legend-dot.badge-stub { background: var(--stub); }

/* 달력 그리드 - FHD 풀사이즈 고정 레이아웃
   grid-template-rows를 auto 한 줄만 명시해서 첫 행(요일 헤더, .cal-weekday 7개)은 내용 높이만큼만 차지하게 하고,
   그 다음부터의 implicit 행(실제 날짜 .cal-cell들)에만 grid-auto-rows가 적용되게 분리한다.
   이 구분이 없으면 요일 헤더도 날짜 셀과 똑같이 minmax(132px, 1fr) 취급을 받아 헤더 행 패딩/폰트를 아무리 줄여도
   행 자체 높이가 줄지 않는 문제가 있었다. */
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto;
  grid-auto-rows: minmax(132px, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex: 1;
}
/* 주간 뷰: 이번주+다음주 2주(2행)를 한 화면에 표시. 요일 행은 월간뷰와 동일하게 auto로 최소화되고,
   날짜 셀 2행이 남는 공간을 나눠가지므로 최소높이를 넉넉히 잡아 월간뷰보다 뚜렷하게 커 보이게 한다. */
.calendar-grid.is-week { grid-auto-rows: minmax(260px, 1fr); }
.cal-weekday { background: var(--bg-sunken); text-align: center; padding: 3px 4px; font-size: 0.72rem; font-weight: 600; color: var(--muted); line-height: 1.2; }
.cal-weekday.sun { color: var(--warn); }
.cal-cell { background: var(--bg-raised); min-height: 132px; padding: 8px; font-size: 0.72rem; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.cal-cell.outside { background: var(--bg-sunken); opacity: 0.55; }
.cal-cell.today { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-daynum-row { display: flex; align-items: baseline; gap: 5px; margin-bottom: 5px; }
.cal-daynum { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: 0.86rem; }
.cal-daynum.holiday, .cal-daynum.sunday { color: var(--warn); }
.cal-holiday-label { font-size: 0.6rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-add-btn {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 5px;
  border: none; background: transparent; color: var(--line-strong); font-size: 0.95rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.12s, background-color 0.12s, color 0.12s;
}
.cal-cell:hover .cal-add-btn { opacity: 1; }
.cal-add-btn:hover { background: var(--bg-sunken); color: var(--muted); }
.cal-events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; flex: 1; }
.cal-event {
  border-radius: 4px; padding: 2px 6px; font-size: 0.66rem; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.5;
  border-left: 3px solid transparent;
}
.cal-event:hover { filter: brightness(0.96); }
.cal-event-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.cal-event-badges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 1px; }
.cal-mini-badge { display: inline-block; font-size: 0.56rem; font-weight: 600; padding: 0px 5px; border-radius: 8px; background: var(--mini-badge-bg); line-height: 1.5; }
.cal-mini-badge.assignee { background: var(--mini-badge-bg-soft); font-weight: 500; }
.cal-more { font-size: 0.62rem; color: var(--accent-ink); cursor: pointer; font-weight: 550; padding: 1px 2px; }
.cal-more:hover { text-decoration: underline; }
.cal-event[draggable="true"] { cursor: grab; }
.cal-event.dragging { opacity: 0.4; }
.cal-cell.drop-target { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }

/* 리스트(아젠다) 뷰 */
.agenda-list { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.agenda-day-group { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.agenda-day-head { padding: 9px 16px; background: var(--bg-sunken); font-weight: 600; font-size: 0.82rem; display: flex; align-items: center; gap: 8px; }
.agenda-day-head .holiday-tag { color: var(--warn); font-weight: 550; font-size: 0.72rem; }
.agenda-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.agenda-item:hover { background: var(--bg-sunken); }
.agenda-item-title { font-weight: 550; font-size: 0.85rem; flex: 1; }
.agenda-item-badges { display: flex; gap: 5px; flex-wrap: wrap; }

/* 일정 상세 보기 */
.event-detail-row { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.82rem; }
.event-detail-row:last-child { border-bottom: none; }
.event-detail-label { width: 84px; flex-shrink: 0; color: var(--muted); font-weight: 550; font-size: 0.74rem; }
.event-detail-value { flex: 1; white-space: pre-wrap; }

/* ---------- 환경설정 ---------- */
.settings-section { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); max-width: 520px; }
.settings-section h3 { font-size: 1rem; margin-bottom: 8px; }
.settings-desc { font-size: 0.82rem; color: var(--muted); margin: 0 0 16px; line-height: 1.6; }
.settings-option-row { display: flex; gap: 8px; }
.settings-option-btn { flex: 1; padding: 12px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink-soft); font-weight: 550; font-size: 0.85rem; cursor: pointer; }
.settings-option-btn:hover { border-color: var(--line-strong); }
.settings-option-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; display: flex; flex-wrap: wrap; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-room-list { max-height: 200px; }
}
/* 업무일지의 직접 입력과 자동 기록은 한 영역 안에서 전체 폭을 사용한다. */
.journal-today-work,.journal-routine-work{width:100%;min-width:0}.journal-note-entry{overflow-wrap:anywhere}
.journal-entry-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}.journal-entry-actions{display:flex;gap:5px;flex-shrink:0}.journal-routine-entry{margin:8px 0;padding:10px 12px;border:1px solid var(--border);border-radius:6px}.journal-calendar{margin:20px 0}.journal-calendar-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.journal-calendar-head>div{display:flex;gap:6px}.journal-calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px}.journal-cal-dow{text-align:center;padding:5px;font-size:.78rem;color:var(--muted)}.journal-cal-day{min-height:64px;border:1px solid var(--border);border-radius:6px;background:var(--surface);padding:6px;text-align:left;display:flex;flex-direction:column;gap:5px}.journal-cal-day:disabled{opacity:.55}.journal-cal-day.has-journal{cursor:pointer;border-color:var(--primary)}.journal-cal-day.blank{border:0;background:transparent}@media(max-width:600px){.journal-cal-day{min-height:48px;padding:4px}.journal-cal-day .badge{font-size:.6rem;padding:2px 4px}.journal-entry-head{align-items:flex-start}.journal-entry-actions{flex-direction:column}}
.journal-cal-day.can-create{cursor:pointer;border-style:dashed}.journal-cal-day.can-create small{color:var(--muted);font-size:.65rem}.journal-edit-modal,.journal-edit-modal .form-field{width:100%}.journal-edit-textarea{display:block;width:100%;min-height:220px;box-sizing:border-box;resize:vertical}.form-help{font-size:.75rem;color:var(--muted);margin-top:10px}

/* ---- 15단계: 사용자 정의 항목(속성) ---- */
.cf-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: 0.75rem; line-height: 1.6; white-space: nowrap; color: var(--ink); }
.cf-chips, .cf-links { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.cf-links a { color: var(--accent); }
.cf-c-gray { background: rgba(128,128,128,0.18); }
.cf-c-brown { background: rgba(150,100,60,0.22); }
.cf-c-orange { background: rgba(240,140,40,0.24); }
.cf-c-yellow { background: rgba(225,185,30,0.28); }
.cf-c-green { background: rgba(60,170,90,0.24); }
.cf-c-blue { background: rgba(60,130,230,0.22); }
.cf-c-purple { background: rgba(150,90,220,0.22); }
.cf-c-pink { background: rgba(230,90,160,0.22); }
.cf-c-red { background: rgba(230,70,70,0.22); }
.cf-chip-x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; font-size: 0.9rem; line-height: 1; }
.cf-empty { color: var(--muted); }
.cf-num { font-variant-numeric: tabular-nums; }
.cf-longtext { white-space: pre-wrap; overflow-wrap: anywhere; }
.cf-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.cf-hint { font-size: 0.8rem; color: var(--muted); margin: 4px 0 12px; }
.cf-form-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line-strong); font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.cf-form-slot { color: var(--muted); font-size: 0.8rem; }
.cf-checkbox, .cf-inline { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.cf-detail { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line-strong); }
.cf-detail-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cf-detail-title { font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-right: auto; }
.cf-value { min-height: 1.4em; }
.cf-inline-row { flex-wrap: wrap; gap: 6px; }
.cf-inline-item { display: inline-flex; align-items: center; gap: 4px; }
.cf-inline-name { color: var(--muted); font-size: 0.72rem; }
.cf-rel { display: flex; flex-direction: column; gap: 6px; }
.cf-rel-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cf-rel-box { position: relative; }
.cf-rel-list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 2px; max-height: 220px; overflow: auto; background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); }
.cf-rel-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; font-size: 0.85rem; color: var(--ink); cursor: pointer; }
.cf-rel-item:hover, .cf-rel-item:focus { background: var(--bg-sunken); }
.cf-rel-empty { padding: 8px 10px; font-size: 0.8rem; color: var(--muted); }
.cf-manager-modal { width: min(760px, calc(100vw - 32px)); max-width: none; }
.cf-mg-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cf-mg-none { padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.cf-mg-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raised); }
.cf-mg-row.is-gone { opacity: 0.75; }
.cf-mg-move { display: flex; gap: 2px; }
.cf-mg-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 240px; min-width: 0; }
.cf-type-icon { display: inline-flex; justify-content: center; min-width: 22px; font-size: 0.8rem; color: var(--muted); }
.cf-mg-type { font-size: 0.75rem; color: var(--muted); }
.cf-mg-mine { display: flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--ink-soft); white-space: nowrap; cursor: pointer; }
.cf-mg-actions { display: flex; gap: 4px; }
.cf-danger { color: var(--warn); }
.cf-mg-add { margin-bottom: 12px; }
.cf-mg-gone { margin: 8px 0 12px; }
.cf-mg-gone summary { cursor: pointer; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.cf-editor { border: 1px solid var(--accent); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: var(--bg-raised); }
.cf-editor-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 10px; }
.cf-ed-extra { display: contents; }
.cf-ed-opts { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.cf-ed-opt { display: flex; align-items: center; gap: 6px; width: 100%; }
.cf-ed-opt input { flex: 1 1 auto; min-width: 0; }
.cf-ed-opt select { width: auto; }
.cf-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
@media (max-width: 640px) { .cf-mg-mine { order: 5; } .cf-cell { max-width: 140px; } }
