:root {
  --orange: #f26f21; --orange-dark: #e05e10; --orange-soft: #fff2ea;
  --blue: #2f6bff; --green: #16a34a; --red: #e23b3b; --amber: #f59e0b;
  --bg: #f4f5f7; --panel: #fff; --line: #e9ebef; --line2: #f0f1f4;
  --text: #22252a; --muted: #6b7280; --muted2: #9aa0a8;
  --rail: 74px; --sub: 236px; --header: 0px;
  --shadow: 0 1px 3px rgba(20,25,40,.06), 0 1px 2px rgba(20,25,40,.04);
  --shadow-lg: 0 10px 30px rgba(20,25,40,.14);
  --radius: 10px;
}
:root[data-theme=dark] {
  --bg:#15171b; --panel:#1c1f24; --line:#2a2e35; --line2:#23272d; --text:#e6e8 eb; --text:#e6e8eb; --muted:#9aa0a8; --muted2:#6b7280; --orange-soft:#3a2a1e; --shadow:none;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Malgun Gothic', '맑은 고딕', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; overflow: hidden; }
[data-fontsize=large] body, body[data-fontsize=large] { font-size: 15px; }
[data-fontsize=small] body, body[data-fontsize=small] { font-size: 13px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--blue); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd3da; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b6bcc6; background-clip: padding-box; }
[data-theme=dark] ::-webkit-scrollbar-thumb { background: #3a3f47; background-clip: padding-box; }
[hidden] { display: none !important; }

/* 로그인 */
.login-wrap { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(135deg, #fff6f0, #f4f5f7); }
.login-card { width: 380px; max-width: 92vw; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 40px 34px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-logo .mark { width: 40px; height: 40px; border-radius: 10px; background: var(--orange); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.login-logo b { font-size: 19px; }
.login-card label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 6px; }
.field { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 9px; padding: 0 13px; background: var(--panel); outline: none; }
.field:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.btn-primary { width: 100%; height: 45px; background: var(--orange); color: #fff; border-radius: 9px; font-weight: 700; margin-top: 22px; transition: .15s; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-primary:disabled { opacity: .6; }
.login-msg { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }
.login-hint { margin-top: 20px; font-size: 12px; color: var(--muted2); line-height: 1.7; border-top: 1px solid var(--line2); padding-top: 14px; }
.demo-badge { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; font-size: 12px; padding: 6px 14px; border-radius: 20px; z-index: 5000; box-shadow: var(--shadow-lg); opacity: .94; }

/* 레이아웃 */
.app { display: none; height: 100vh; }
.app.on { display: grid; grid-template-columns: var(--rail) var(--sub) 1fr; }
.app.no-sub { grid-template-columns: var(--rail) 1fr; }
.app.no-sub .sub { display: none; }
.rail { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 4px; }
.rail .logo { width: 44px; height: 44px; border-radius: 12px; background: var(--orange); color: #fff; display: grid; place-items: center; font-weight: 800; margin-bottom: 12px; font-size: 17px; }
.rail-item { width: 58px; padding: 9px 0 7px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); position: relative; transition: .12s; }
.rail-item svg { width: 22px; height: 22px; }
.rail-item span { font-size: 11px; }
.rail-item:hover { background: var(--line2); color: var(--text); }
.rail-item.on { color: var(--orange); background: var(--orange-soft); }
.rail-item .dot { position: absolute; top: 6px; right: 12px; min-width: 16px; height: 16px; padding: 0 4px; background: var(--red); color: #fff; border-radius: 10px; font-size: 10px; display: grid; place-items: center; font-weight: 700; }
.rail .spacer { flex: 1; }
.rail .me { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--orange-soft); color: var(--orange); display: grid; place-items: center; font-weight: 700; cursor: pointer; border: 2px solid transparent; }
.rail .me img { width: 100%; height: 100%; object-fit: cover; }

.sub { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.sub-head { padding: 18px 18px 12px; }
.sub-head h1 { font-size: 17px; margin: 0; font-weight: 700; }
.sub-body { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.compose-btn { margin: 4px 14px 10px; height: 42px; background: var(--orange); color: #fff; border-radius: 21px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 7px; box-shadow: 0 2px 8px rgba(242,111,33,.3); transition: .15s; }
.compose-btn:hover { background: var(--orange-dark); }
.compose-btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text); font-size: 13.5px; position: relative; }
.nav-link:hover { background: var(--line2); }
.nav-link.on { background: var(--orange-soft); color: var(--orange-dark); font-weight: 600; }
.nav-link .ico { width: 18px; display: grid; place-items: center; color: var(--muted); }
.nav-link.on .ico { color: var(--orange); }
.nav-link .cnt { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.nav-link .cnt.badge { background: var(--red); color: #fff; padding: 1px 7px; border-radius: 10px; }
.nav-sep { height: 1px; background: var(--line2); margin: 10px 12px; }
.nav-group-title { font-size: 11.5px; color: var(--muted2); padding: 10px 12px 5px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.nav-group-title button { color: var(--muted2); font-size: 15px; line-height: 1; }

.main { overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.toolbar { height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); flex-shrink: 0; }
.toolbar h2 { font-size: 16px; margin: 0; font-weight: 700; }
.toolbar .count { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 4px; }
.toolbar .grow { flex: 1; }
.content { flex: 1; overflow: hidden; display: flex; }

/* 버튼 */
.btn { height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; transition: .12s; white-space: nowrap; }
.btn:hover { background: var(--line2); }
.btn.pri { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn.pri:hover { background: var(--orange-dark); }
.btn.blue { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: #fdecec; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--line2); color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; background: var(--line2); font-size: 12px; color: var(--muted); }
.chip.on { background: var(--orange-soft); color: var(--orange-dark); font-weight: 600; }
.search { display: flex; align-items: center; gap: 7px; height: 34px; border: 1px solid var(--line); border-radius: 20px; padding: 0 12px; background: var(--panel); }
.search input { border: none; outline: none; width: 180px; background: none; }

/* 목록 */
.list { flex: 1; overflow-y: auto; }
.list-empty { padding: 80px 20px; text-align: center; color: var(--muted2); }
.list-empty svg { width: 60px; height: 60px; opacity: .4; margin-bottom: 12px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 14px; }
.pager button { min-width: 30px; height: 30px; border-radius: 7px; color: var(--muted); }
.pager button:hover { background: var(--line2); }
.pager button.on { background: var(--orange); color: #fff; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
table.grid td { padding: 11px 12px; border-bottom: 1px solid var(--line2); }
table.grid tr:hover td { background: var(--orange-soft); cursor: pointer; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 5px; font-weight: 600; }
.tag.gray { background: var(--line2); color: var(--muted); }
.tag.green { background: #e7f6ec; color: var(--green); }
.tag.red { background: #fdecec; color: var(--red); }
.tag.amber { background: #fef3d9; color: #b7791f; }
.tag.blue { background: #eaf1ff; color: var(--blue); }
[data-theme=dark] .tag.green{background:#12331f}[data-theme=dark] .tag.red{background:#3a1e1e}[data-theme=dark] .tag.blue{background:#1a2740}[data-theme=dark] .tag.amber{background:#3a2f14}

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-dark); display: grid; place-items: center; font-weight: 700; font-size: 13px; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd0d8; border: 2px solid var(--panel); }
.online-dot.on { background: var(--green); }

/* 메일 목록 행 */
.mail-row { display: grid; grid-template-columns: 30px 26px 1fr auto; gap: 10px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--line2); cursor: pointer; }
.mail-row:hover { background: var(--orange-soft); }
.mail-row.unread { background: #fbfcfe; }
.mail-row.unread .m-subj, .mail-row.unread .m-from { font-weight: 700; }
.mail-row.sel { background: var(--orange-soft); }
.mail-row .m-from { font-size: 13.5px; }
.mail-row .m-subj { color: var(--text); font-size: 13.5px; }
.mail-row .m-snippet { color: var(--muted); font-weight: 400 !important; font-size: 12.5px; }
.mail-row .m-meta { text-align: right; color: var(--muted); font-size: 12px; white-space: nowrap; }
.star { color: #d4d8de; }
.star.on { color: #f5b301; }
.flag-attach { color: var(--muted2); }

/* 상세 패널 */
.split { display: flex; height: 100%; width: 100%; }
.split.bottom { flex-direction: column; }
.split .pane-list { flex: 1; min-width: 0; overflow: hidden; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.split.bottom .pane-list { border-right: none; border-bottom: 1px solid var(--line); flex: none; height: 45%; }
.split .pane-detail { flex: 1.3; min-width: 0; overflow-y: auto; background: var(--panel); }
.detail-empty { display: grid; place-items: center; height: 100%; color: var(--muted2); }
/* 섹터 크기 조절 손잡이 */
.split-resizer { flex: 0 0 6px; align-self: stretch; cursor: col-resize; background: transparent; position: relative; z-index: 5; }
.split-resizer::after { content: ''; position: absolute; left: 2px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .12s; }
.split-resizer:hover::after, .split-resizer.drag::after { background: var(--orange); }
.split-resizer.v { flex: 0 0 6px; width: 100%; cursor: row-resize; }
.split-resizer.v::after { left: 0; right: 0; top: 2px; bottom: auto; width: auto; height: 2px; }
.sub-resizer { position: fixed; top: 0; bottom: 0; width: 7px; z-index: 300; cursor: col-resize; left: calc(var(--rail) + var(--sub) - 3px); }
.sub-resizer::after { content: ''; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px; background: transparent; transition: background .12s; }
.sub-resizer:hover::after, .sub-resizer.drag::after { background: var(--orange); }
@media (max-width: 860px) { .sub-resizer { display: none !important; } }

/* ───── AI 업무 도우미 — 우하단 도크 (판매관리 AI창 방식) ───── */
/* 떠 있는 AI 버튼 — 좌측(레일 오른쪽 목록 하단 빈 공간)에 두어 우측 채팅 입력창 등과 겹치지 않게 한다 */
.ai-launcher { position: fixed; left: 88px; right: auto; bottom: 66px; z-index: 690; display: flex; align-items: center; gap: 6px; padding: 11px 16px 11px 14px; border-radius: 26px; background: var(--orange); color: #fff; border: none; box-shadow: 0 6px 20px rgba(242,111,33,.4); cursor: pointer; font-size: 14px; font-weight: 600; }
.ai-launcher span:first-child { font-size: 18px; }
.ai-launcher.hide { display: none; }
.ai-dock { position: fixed; right: 16px; bottom: 16px; z-index: 700; width: var(--aiw, 392px); max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.22); display: none; flex-direction: column; overflow: hidden; }
.ai-dock.on { display: flex; }
.ai-dock.drop { outline: 3px dashed var(--orange); outline-offset: -3px; }
.ai-dhead { background: var(--orange); color: #fff; padding: 9px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.ai-dhead .ic { font-size: 16px; }
.ai-dhead .ttl { font-size: 13px; font-weight: 600; }
.ai-dhead .st { font-size: 10.5px; color: #ffe1cd; flex: 1; }
.ai-dhead button { background: rgba(255,255,255,.18); border: none; color: #fff; width: 22px; height: 22px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; padding: 0; line-height: 1; }
.ai-dhead button:hover { background: rgba(255,255,255,.34); }
.ai-ctx { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--line2); min-height: 20px; flex-wrap: wrap; }
.ai-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 260px; background: var(--orange-soft); color: var(--orange); border-radius: 8px; padding: 3px 9px; font-size: 12px; }
.ai-chip.muted { background: var(--line2); color: var(--muted); }
.ai-chip .ellip, .ai-att .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-chip-x { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; display: flex; }
.ai-msgs { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); height: var(--aih, 300px); }
.ai-hello { text-align: center; color: var(--muted); margin: auto; display: flex; flex-direction: column; gap: 10px; align-items: center; line-height: 1.7; font-size: 13px; }
.ai-warn { background: #fef3c7; color: #92400e; border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.ai-msg { display: flex; flex-direction: column; gap: 4px; }
.ai-msg.user { align-items: flex-end; }
.ai-bubble { max-width: 88%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.ai-msg.user .ai-bubble { background: var(--orange); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.assistant .ai-bubble { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-bottom-left-radius: 4px; }
.ai-bubble.loading { color: var(--muted); }
.ai-msg-atts { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 2px; }
.ai-msg-atts img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.ai-actions { display: flex; gap: 6px; margin-top: 2px; }
.ai-a { display: inline-flex; align-items: center; gap: 3px; background: none; border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; font-size: 12px; color: var(--muted); cursor: pointer; }
.ai-a:hover { border-color: var(--orange); color: var(--orange); }
.ai-ask-opts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-ask-opt { background: var(--bg2, #f6f7f9); border: 1px solid var(--line); border-radius: 14px; padding: 6px 12px; font-size: 12.5px; color: var(--ink, #222); cursor: pointer; }
.ai-ask-opt:hover { border-color: var(--orange); color: var(--orange); background: #fff7f1; }
/* AI 첫 화면 예시 명령 */
.ai-ex { width: 100%; margin-top: 12px; text-align: left; }
.ai-ex-cat { font-size: 11.5px; font-weight: 700; color: var(--muted); margin: 10px 2px 5px; }
.ai-ex-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-ex-chip { background: var(--bg2, #f6f7f9); border: 1px solid var(--line); border-radius: 13px; padding: 6px 11px; font-size: 12px; color: var(--ink, #222); cursor: pointer; text-align: left; }
.ai-ex-chip:hover { border-color: var(--orange); color: var(--orange); background: #fff7f1; }
.ai-ex-more { width: 100%; margin-top: 14px; background: var(--orange-soft, #fff1e8); color: var(--orange-dark, #c65213); border: none; border-radius: 8px; padding: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.ai-ex-more:hover { background: #ffe4d3; }
/* 결재 부서 문서함 — 폴더 트리 */
.docbox { flex: 1; display: flex; min-height: 0; }
/* 전자결재 — 전통 결재란(도장 칸) */
.appr-box { display: flex; border: 1.5px solid var(--text); border-radius: 4px; overflow: hidden; align-self: flex-start; background: var(--panel); }
.appr-side { display: grid; place-items: center; padding: 0 5px; font-size: 12px; font-weight: 800; color: var(--muted); border-right: 1.5px solid var(--text); letter-spacing: 4px; writing-mode: vertical-rl; text-orientation: upright; }
.appr-col { width: 62px; text-align: center; border-right: 1px solid var(--line); }
.appr-col:last-child { border-right: none; }
.appr-h { font-size: 10.5px; color: var(--muted); padding: 3px 0; border-bottom: 1px solid var(--line); background: var(--line2); font-weight: 600; }
.appr-sign { height: 50px; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.appr-seal { width: 38px; height: 38px; border: 2px solid var(--red); border-radius: 6px; color: var(--red); display: grid; place-items: center; font-size: 12px; font-weight: 800; transform: rotate(-8deg); opacity: .92; }
.appr-seal.reject { transform: none; font-size: 11px; }
.appr-seal.blank { border: none; }
.appr-nm { padding: 3px 1px; border-bottom: 1px solid var(--line); }
.appr-name { font-size: 11px; font-weight: 600; }
.appr-pos { font-size: 9.5px; color: var(--muted); }
.appr-dt { font-size: 9.5px; color: var(--muted); padding: 3px 1px; min-height: 15px; }
.appr-rr { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; font-size: 12.5px; color: var(--text); display: flex; flex-direction: column; gap: 3px; }
.appr-rr b { color: var(--muted); margin-right: 4px; }
.doc-tree { width: 232px; flex-shrink: 0; border-right: 1px solid var(--line2); overflow-y: auto; padding: 10px 4px; background: var(--bg2, #fafbfc); }
.doc-list { flex: 1; overflow-y: auto; padding: 14px 20px; min-width: 0; }
.doc-frow { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 7px; cursor: pointer; font-size: 13.5px; color: var(--ink, #222); }
.doc-frow:hover { background: var(--hover, #eef1f5); }
.doc-frow.on { background: #fff1e8; color: var(--orange); font-weight: 600; }
.doc-frow.drop-hi { outline: 2px dashed var(--orange); outline-offset: -2px; background: #fff7f1; }
.doc-frow .doc-fic { display: inline-flex; color: var(--muted); }
.doc-frow.on .doc-fic { color: var(--orange); }
.doc-frow .doc-fname { flex: 1; min-width: 0; }
.doc-frow .doc-fcnt { font-size: 12px; color: var(--muted); }
.ai-foot { border-top: 1px solid var(--line); padding: 8px 10px 10px; background: var(--panel); }
.ai-atts { display: none; gap: 6px; flex-wrap: wrap; margin-bottom: 7px; }
.ai-att { display: inline-flex; align-items: center; gap: 5px; max-width: 170px; background: var(--surface-2, var(--line2)); border: 1px solid var(--line); border-radius: 10px; padding: 4px 7px; font-size: 11.5px; }
.ai-att img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.ai-att .ai-att-ic { font-size: 15px; }
.ai-att.mini { padding: 2px 8px; }
.ai-att-x { background: none; border: none; cursor: pointer; color: var(--muted); display: flex; padding: 0; }
.ai-quick { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-q { background: var(--orange-soft); color: var(--orange); border: none; border-radius: 14px; padding: 5px 11px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.ai-q:hover { background: var(--orange); color: #fff; }
.ai-inputbar { display: flex; align-items: flex-end; gap: 6px; }
.ai-input-ta { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font: inherit; font-size: 13.5px; line-height: 1.5; max-height: 160px; background: var(--bg); color: var(--text); }
.ai-input-ta:focus { outline: none; border-color: var(--orange); }
.ai-send { width: 38px; height: 38px; border-radius: 50%; background: var(--orange); color: #fff; border: none; cursor: pointer; display: grid; place-items: center; flex: none; }
.ai-dock.min .ai-ctx, .ai-dock.min .ai-msgs, .ai-dock.min .ai-foot { display: none; }
.ai-dock .rz { position: absolute; z-index: 6; touch-action: none; }
.ai-dock .rz.l { left: 0; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.ai-dock .rz.t { left: 0; right: 0; top: 0; height: 7px; cursor: ns-resize; }
.ai-dock .rz.c { left: 0; top: 0; width: 17px; height: 17px; cursor: nwse-resize; z-index: 7; }
.ai-dock .rz.c::after { content: ''; position: absolute; left: 4px; top: 4px; width: 8px; height: 8px; border-left: 2px solid var(--muted); border-top: 2px solid var(--muted); }
.ai-dock .rz.l:hover, .ai-dock .rz.t:hover { background: var(--orange-soft); }
.ai-dock.min .rz { display: none; }
body.ai-rzing { user-select: none; }
.ai-dropveil { position: fixed; inset: 0; z-index: 800; display: none; align-items: center; justify-content: center; background: rgba(242,111,33,.72); backdrop-filter: blur(2px); pointer-events: none; }
.ai-dropveil.on { display: flex; }
.ai-dropveil .box { background: #fff; border-radius: 14px; padding: 26px 34px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); max-width: 460px; }
.ai-dropveil .box b { display: block; font-size: 19px; margin-bottom: 6px; color: var(--orange); }
.ai-dropveil .box span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
@media (max-width: 860px) { .ai-dock { width: calc(100vw - 24px) !important; right: 12px; left: 12px; } .ai-dock .rz.l, .ai-dock .rz.c { display: none; } .ai-launcher { bottom: 128px; right: 14px; left: auto; } }
/* ───── 공용 리치 에디터 (작성 툴) ───── */
.rte { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 1px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line2); background: var(--bg); position: sticky; top: 0; z-index: 2; }
.rte-b { min-width: 28px; height: 28px; padding: 0 6px; border: 1px solid transparent; background: none; border-radius: 6px; cursor: pointer; color: var(--text); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.rte-b b { font-weight: 700; font-size: 13.5px; }
.rte-b.i b { font-style: italic; } .rte-b.u b { text-decoration: underline; } .rte-b.s b { text-decoration: line-through; }
.rte-b:hover { background: var(--line2); }
.rte-b.on { background: var(--orange-soft); color: var(--orange); }
.rte-b svg { width: 17px; height: 17px; }
.rte-color span:first-child { font-size: 13px; }
.rte-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.rte-sel { height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font-size: 12px; padding: 0 4px; margin: 0 1px; cursor: pointer; max-width: 110px; }
.rte-body { padding: 14px 16px; outline: none; line-height: 1.6; font-size: 14px; overflow-y: auto; color: var(--text); }
.rte-body:empty:before { content: attr(data-ph); color: var(--muted); }
.rte-body blockquote { border-left: 3px solid var(--line); margin: 8px 0; padding: 4px 14px; color: var(--muted); }
.rte-body h2 { font-size: 20px; margin: 12px 0 6px; } .rte-body h3 { font-size: 16px; margin: 10px 0 5px; }
.rte-body img { max-width: 100%; height: auto; }
.rte-body table { border-collapse: collapse; margin: 6px 0; }
.rte-body td, .rte-body th { border: 1px solid var(--line); padding: 5px 8px; min-width: 40px; }
.rte-body ul, .rte-body ol { padding-left: 24px; margin: 6px 0; }
.rte-body a { color: var(--orange); }
.rte-body img { cursor: pointer; }
.rte-imgres { position: absolute; display: none; border: 1.5px solid var(--orange); box-sizing: border-box; pointer-events: none; z-index: 5; }
.rte-imgres-h { position: absolute; width: 13px; height: 13px; background: var(--orange); border: 2px solid #fff; border-radius: 2px; pointer-events: auto; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.rte-imgres-h.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.rte-imgres-h.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.rte-imgres-del { position: absolute; top: -11px; right: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--red); color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); pointer-events: auto; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 15px; line-height: 1; font-weight: 700; }
body.rte-rzing { user-select: none; }
/* 메신저 파일 끌어다 놓기 안내 */
.chat-dropveil { position: absolute; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; background: rgba(242,111,33,.72); backdrop-filter: blur(2px); pointer-events: none; }
.chat-dropveil.on { display: flex; }
.chat-dropveil .box { background: #fff; border-radius: 14px; padding: 24px 32px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.chat-dropveil .box b { display: block; font-size: 18px; color: var(--orange); margin-bottom: 5px; }
.chat-dropveil .box span { font-size: 12.5px; color: var(--muted); }

.mail-view { padding: 24px 28px; }
.mail-view h1 { font-size: 20px; margin: 0 0 16px; line-height: 1.4; }
.mail-view .mv-head { display: flex; gap: 12px; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--line2); }
.mail-view .mv-body { padding: 22px 2px; line-height: 1.7; font-size: 14px; word-break: break-word; }
.mail-view .mv-body img { max-width: 100%; height: auto; }
.mail-view .mv-body table { max-width: 100%; }
.attach-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 16px; }
.attach-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.attach-item .fi { width: 32px; height: 32px; border-radius: 7px; background: var(--line2); display: grid; place-items: center; color: var(--muted); }
.banner { padding: 9px 14px; border-radius: 8px; font-size: 12.5px; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.banner.warn { background: #fef6e7; color: #b7791f; }
.banner.danger { background: #fdecec; color: var(--red); }
.banner.info { background: #eef4ff; color: var(--blue); }

/* 폼 */
.form-row { margin-bottom: 14px; }
.form-row > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
textarea.field { height: auto; padding: 10px 13px; resize: vertical; line-height: 1.6; }
select.field { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.4' fill='none'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.toggle { width: 40px; height: 22px; border-radius: 12px; background: #cfd3da; position: relative; transition: .15s; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; }
.toggle.on { background: var(--orange); }
.toggle.on::after { left: 20px; }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,40,.42); display: grid; place-items: center; z-index: 1000; padding: 20px; }
.modal { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); max-width: 92vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line2); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line2); display: flex; justify-content: flex-end; gap: 8px; }

/* 알림 토스트 */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 2000; }
.toast { background: var(--panel); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 260px; max-width: 340px; border-left: 3px solid var(--orange); animation: slideIn .25s; cursor: pointer; }
.toast b { font-size: 13.5px; }
.toast p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }

/* 메신저 */
.chat-list { flex: 1; overflow-y: auto; }
.chat-item { display: flex; gap: 11px; padding: 11px 14px; cursor: pointer; align-items: center; }
.chat-item:hover { background: var(--line2); }
.chat-item.on { background: var(--orange-soft); }
.chat-item .ci-body { flex: 1; min-width: 0; }
.chat-item .ci-top { display: flex; justify-content: space-between; align-items: baseline; }
.chat-item .ci-name { font-weight: 600; font-size: 13.5px; }
.chat-item .ci-time { font-size: 11px; color: var(--muted2); }
.chat-item .ci-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-unread { background: var(--orange); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-head { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 3px; }
.msg { display: flex; gap: 9px; margin-top: 10px; max-width: 74%; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble { background: var(--panel); padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; box-shadow: var(--shadow); word-break: break-word; }
.msg.me .bubble { background: var(--orange); color: #fff; }
.msg .mmeta { font-size: 10.5px; color: var(--muted2); align-self: flex-end; margin: 0 4px; white-space: nowrap; }
.msg-sys { text-align: center; font-size: 12px; color: var(--muted2); margin: 12px 0; }
.msg-name { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.chat-input { padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-end; }
.chat-input textarea { flex: 1; border: 1px solid var(--line); border-radius: 20px; padding: 10px 15px; resize: none; max-height: 120px; outline: none; line-height: 1.5; }
.chat-input textarea:focus { border-color: var(--orange); }
/* 답장(인용) 입력 바 */
.chat-inwrap { display: flex; flex-direction: column; }
.reply-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--orange-soft); border-top: 1px solid var(--line); border-left: 3px solid var(--orange); }
.reply-bar-body { flex: 1; min-width: 0; }
.reply-bar-name { font-size: 12px; font-weight: 700; color: var(--orange); }
.reply-bar-text { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 말풍선 내 답장 인용 */
.reply-quote { border-left: 3px solid var(--orange); background: rgba(0,0,0,.04); border-radius: 6px; padding: 4px 8px; margin-bottom: 4px; font-size: 12px; max-width: 260px; }
.reply-quote-name { font-weight: 700; color: var(--orange); margin-right: 6px; }
.reply-quote-text { color: var(--muted); }
.msg.me .reply-quote { margin-left: auto; }
.ci-unread.muted-badge { background: var(--muted); }
.msg-edited { margin-left: 4px; font-size: 11px; }
/* 내 메일함 폴더 펼침 화살표 */
.fold-arrow { width: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted2); cursor: pointer; flex-shrink: 0; }
.fold-arrow:hover { color: var(--orange); }
.fold-arrow.open { transform: rotate(90deg); }
/* 메일 드래그 → 폴더 이동 */
.mail-row.dragging { opacity: .5; }
body.mail-dragging .nav-link { transition: background .1s; }
.nav-link.drop-hi { background: var(--orange); color: #fff; outline: 2px dashed #fff; outline-offset: -3px; }
.nav-link.drop-hi .ico { color: #fff; }
/* 메시지 공감(리액션) */
.msg-reacts { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.react-chip { font-size: 12px; padding: 1px 7px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel); line-height: 1.6; }
.react-chip.on { background: var(--orange-soft); border-color: var(--orange); }
.msg.me .msg-reacts { justify-content: flex-end; }
/* 이모지 입력기 */
.emoji-panel { position: fixed; z-index: 4000; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; width: 300px; display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.emoji-btn { font-size: 20px; padding: 3px; border-radius: 6px; background: none; }
.emoji-btn:hover { background: var(--line2); }
/* 방 안 메시지 검색 */
.chat-search { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-search input { flex: 1; border: 1px solid var(--line); border-radius: 18px; padding: 7px 14px; outline: none; }
.chat-search input:focus { border-color: var(--orange); }
.msg.search-hit .bubble { box-shadow: 0 0 0 2px var(--orange); border-radius: 12px; }
/* 방 공지(카카오톡 공지) */
.room-notice { display: flex; align-items: center; gap: 8px; margin: 8px 12px 0; padding: 8px 12px; background: #fffbe6; border: 1px solid #fde68a; border-radius: 10px; font-size: 13px; }
[data-theme=dark] .room-notice { background: #3a3320; border-color: #6b5a1e; }
.room-notice .rn-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 일정 할 일(To-do) */
.todo-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 7px; }
.todo-row:hover { background: var(--line2); }
.todo-row .todo-text { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-row.done .todo-text { text-decoration: line-through; color: var(--muted2); }
.todo-row .icon-btn.sm { width: 24px; height: 24px; opacity: 0; }
.todo-row:hover .icon-btn.sm { opacity: 1; }

/* 조직도 트리 */
.tree-node { padding: 7px 10px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.tree-node:hover { background: var(--line2); }
.tree-node.on { background: var(--orange-soft); color: var(--orange-dark); font-weight: 600; }

/* 캘린더 */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; flex: 1; border-left: 1px solid var(--line2); border-top: 1px solid var(--line2); }
.cal-cell { border-right: 1px solid var(--line2); border-bottom: 1px solid var(--line2); padding: 5px 7px; overflow: hidden; min-height: 90px; cursor: pointer; position: relative; }
.cal-cell:hover { background: var(--line2); }
.cal-cell.other { background: #fafbfc; color: var(--muted2); }
[data-theme=dark] .cal-cell.other{background:#191c20}
.cal-cell .cd { font-size: 12.5px; font-weight: 600; }
.cal-cell.today .cd { background: var(--orange); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.cal-cell.sun .cd, .cal-cell.hol .cd { color: var(--red); }
.cal-cell.sat .cd { color: var(--blue); }
.cal-ev { font-size: 11.5px; padding: 2px 6px; border-radius: 5px; margin-top: 3px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head div { text-align: center; padding: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.cal-head div:first-child { color: var(--red); }
.cal-head div:last-child { color: var(--blue); }

.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--orange); border-radius: 50%; animation: sp 0.7s linear infinite; margin: 40px auto; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading-cover { display: grid; place-items: center; flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
hr.sep { border: none; border-top: 1px solid var(--line2); margin: 16px 0; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.progress { height: 8px; background: var(--line2); border-radius: 5px; overflow: hidden; }
.progress > div { height: 100%; background: var(--orange); transition: width .3s; }

@media (max-width: 900px) {
  .app.on, .app.no-sub { grid-template-columns: 1fr; }
  .rail { flex-direction: row; width: 100%; height: 58px; position: fixed; bottom: 0; left: 0; z-index: 500; padding: 0; border-top: 1px solid var(--line); border-right: none; justify-content: space-around; }
  .rail .logo, .rail .spacer, .rail .me { display: none; }
  .rail-item { width: auto; flex: 1; padding: 8px 0; border-radius: 0; }
  .rail-item span { font-size: 10px; }
  .sub { position: fixed; inset: 0 0 58px 0; z-index: 400; }
  .app.show-detail .sub { display: none; }
  .main { position: fixed; inset: 0 0 58px 0; }
  /* 모바일: 메일 등 목록+본문 분할은 세로로 쌓아 둘 다 보이게 */
  .split { flex-direction: column; }
  .split .pane-list { display: block !important; width: 100% !important; max-height: 45vh; border-right: none; border-bottom: 6px solid var(--line2); }
  .split .pane-detail { display: block; width: 100% !important; }
  .split .split-resizer { display: none; }
  .mobile-only { display: inline-flex !important; }
  /* 모바일 '메뉴' 되돌아가기 버튼 — 내용(main)에서 좌측 메뉴(sub)로 */
  .mnav-back { display: none; }
  .app.show-detail .mnav-back { display: inline-flex; position: fixed; left: 10px; bottom: 66px; z-index: 460; align-items: center; gap: 5px; background: var(--orange); color: #fff; border: none; border-radius: 20px; padding: 9px 15px; font-size: 13px; font-weight: 700; box-shadow: 0 3px 10px rgba(0,0,0,.2); }
  /* 메신저 채팅 전체화면: 하단 탭바 숨기고 입력창을 맨 아래로 (카카오톡식) */
  .app.chat-open .rail { display: none; }
  .app.chat-open .main { bottom: 0; }
  .app.chat-open .mnav-back { display: none !important; }
  .app.chat-open .ai-launcher { display: none; }
}
.mobile-only { display: none; }
.mnav-back { display: none; }
