:root {
  --bg: #f6f7f5; --panel: #ffffff; --side: #eef1ee; --ink: #1d2320; --muted: #69736e;
  --line: #dde3df; --accent: #1f6f5c; --accent-ink: #ffffff; --soft: #e3f0eb;
  --warn: #b5531c; --warn-soft: #fbeee4; --mine: #e8f2ee;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --panel: #1b201e; --side: #181d1b; --ink: #e7ece9; --muted: #95a19b;
    --line: #2b3330; --accent: #4fb39a; --accent-ink: #0d1412; --soft: #1f3530;
    --warn: #f0a06b; --warn-soft: #3a2a1f; --mine: #1e2c28;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--muted); font-weight: 500; padding: 6px 10px; text-align: left; }
button.ghost:hover { color: var(--ink); }
.small { font-size: 13px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* 로그인 */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; text-align: center; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-card form { display: grid; gap: 8px; margin-top: 16px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }

/* 레이아웃 */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100dvh; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); padding: 14px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 12px; }
.side-head img { border-radius: 7px; }
.side-label { font-size: 12px; color: var(--muted); padding: 12px 8px 4px; }
#channels a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
#channels a:hover { background: var(--soft); }
#channels a.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.badge { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--warn); color: #fff; font-size: 12px; text-align: center; }
#people { list-style: none; margin: 0; padding: 0 8px; font-size: 14px; }
#people li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.dot.on { background: #2fb37a; }
#people .when { margin-left: auto; font-size: 12px; color: var(--muted); }
#logout { margin-top: auto; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h2 { margin: 0; font-size: 17px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: transparent; color: var(--ink); padding: 6px 8px; font-size: 18px; border-radius: 8px; cursor: pointer; }
#menu { display: none; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.conn.live { background: #2fb37a; }

/* 메시지 */
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.empty { margin: auto; color: var(--muted); text-align: center; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; max-width: 760px; }
.msg.mine { background: var(--mine); align-self: flex-end; }
.msg-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.msg-head .who { color: var(--ink); font-weight: 700; font-size: 14px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--soft); color: var(--accent); font-weight: 600; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.msg-body { white-space: normal; word-break: break-word; }
.msg-body p { margin: 0 0 6px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 13px; }
.msg-body code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.msg-body a { color: var(--accent); }
.msg.worklog .msg-body { max-height: 7.5em; overflow: hidden; position: relative; }
.msg.worklog.open .msg-body { max-height: none; }
.more { background: none; color: var(--accent); padding: 2px 0; font-size: 13px; font-weight: 600; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.file { background: var(--bg); border: 1px solid var(--line); color: var(--ink); font-weight: 500; font-size: 13px; padding: 4px 10px; border-radius: 8px; }
.held { margin-top: 6px; font-size: 13px; color: var(--warn); }
.deliv { margin-top: 4px; font-size: 12px; color: var(--muted); }
.deliv .bad { color: var(--warn); }

/* 입력창 */
.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.chips { flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.chips .lbl { color: var(--muted); }
.chip { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 3px 10px; border-radius: 14px; font-weight: 500; font-size: 13px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#kind { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--bg); }
#body { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); max-height: 40vh; }
.attached { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.attached span { background: var(--soft); padding: 2px 8px; border-radius: 8px; }

/* 모바일 */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
  #menu { display: inline-block; }
  .msg { max-width: 100%; }
  #kind { max-width: 92px; }
}
