:root {
  --accent: #5b4cf0;
  --accent-soft: #eeecff;
  --side-bg: #1e1c2a;
  --side-fg: #c9c7d6;
  --side-hover: #2c2a3c;
  --side-active: #5b4cf0;
  --bg: #ffffff;
  --bg-soft: #f6f6f9;
  --fg: #1d1c21;
  --muted: #6b6a75;
  --border: #e6e5ec;
  --mention: #fff4d6;
  --bot: #d97757;
  --radius: 10px;
  font-family: 'Pretendard', 'Malgun Gothic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--fg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; }

/* ---------- 로그인 ---------- */
.login { height: 100%; display: grid; place-items: center; background: linear-gradient(135deg, #1e1c2a, #3a2f8f); }
.login-card { background: #fff; padding: 40px 48px; border-radius: 16px; text-align: center; width: min(400px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card .logo { font-size: 44px; }
.login-card h1 { margin: 8px 0 6px; font-size: 22px; }
.btn-google { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; padding: 11px 20px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-weight: 600; }
.btn-google:hover { background: var(--bg-soft); }

/* ---------- 레이아웃 ---------- */
.app { display: flex; height: 100%; }
.sidebar { width: 250px; flex-shrink: 0; background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; }
.workspace { padding: 16px; font-weight: 700; font-size: 16px; color: #fff; border-bottom: 1px solid #2f2d40; }
.side-scroll { flex: 1; overflow-y: auto; padding: 10px 8px; }
.side-section { margin-top: 14px; }
.side-title { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #8f8da0; }
.side-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: 0; background: none; color: inherit; border-radius: 6px; text-align: left; }
.side-item:hover { background: var(--side-hover); }
.side-item.active { background: var(--side-active); color: #fff; }
.side-item.unread .label { color: #fff; font-weight: 700; }
.side-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .hash { width: 18px; text-align: center; opacity: .7; }
.badge { background: #e5484d; color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.claude-item { margin-bottom: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #555; flex-shrink: 0; }
.dot.on { background: #2fbf71; }
.me-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid #2f2d40; }
.me-bar .label { flex: 1; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 15px; padding: 4px 6px; border-radius: 6px; line-height: 1; }
.icon-btn:hover { background: rgba(127,127,127,.18); }

.avatar { width: 36px; height: 36px; border-radius: 8px; background: #8b7cf6; color: #fff; display: inline-grid; place-items: center; font-weight: 700; flex-shrink: 0; overflow: hidden; background-size: cover; background-position: center; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; border-radius: 5px; }
.avatar.bot { background: var(--bot); }

/* ---------- 채팅 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
.chat-title { display: flex; flex-direction: column; min-width: 0; }
.chat-title strong { font-size: 16px; }
.header-actions { display: flex; gap: 6px; align-items: center; }
.search { border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 220px; background: var(--bg-soft); }
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: #fff; }

.messages { flex: 1; overflow-y: auto; padding: 12px 0 8px; }
.day-divider { display: flex; align-items: center; gap: 10px; margin: 14px 18px 6px; color: var(--muted); font-size: 12px; }
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.msg { display: flex; gap: 10px; padding: 4px 18px; }
.msg:hover { background: var(--bg-soft); }
.msg.cont { padding-top: 1px; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg.mentioned { background: var(--mention); }
.msg .body { min-width: 0; flex: 1; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .meta .name { font-weight: 700; }
.msg .meta .bot-tag { font-size: 10px; background: var(--bot); color: #fff; border-radius: 4px; padding: 1px 5px; font-weight: 700; }
.msg .meta time { color: var(--muted); font-size: 11px; }
.msg .text { line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; }
.msg .text p { margin: 0 0 4px; }
.msg .text p:last-child { margin-bottom: 0; }
.msg .text ul, .msg .text ol { margin: 4px 0; padding-left: 22px; }
.msg .text h1, .msg .text h2, .msg .text h3 { font-size: 15px; margin: 8px 0 4px; }
.msg .text code { background: #f0eff4; border-radius: 4px; padding: 1px 5px; font-family: Consolas, monospace; font-size: 13px; }
.msg .text pre { background: #1e1c2a; color: #eee; border-radius: 8px; padding: 10px 12px; overflow-x: auto; }
.msg .text pre code { background: none; color: inherit; padding: 0; }
.msg .text a { color: var(--accent); }
.msg .text .mention { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.msg .text table { border-collapse: collapse; margin: 6px 0; }
.msg .text th, .msg .text td { border: 1px solid var(--border); padding: 4px 8px; }

.file-card { display: inline-flex; align-items: center; gap: 10px; margin-top: 6px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; max-width: 380px; }
.file-card .ficon { font-size: 22px; }
.file-card .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.file-card button { margin-left: auto; border: 1px solid var(--border); background: var(--bg-soft); border-radius: 6px; padding: 4px 10px; }
.img-preview { display: block; margin-top: 6px; max-width: 360px; max-height: 280px; border-radius: var(--radius); border: 1px solid var(--border); cursor: zoom-in; }

.typing { min-height: 20px; padding: 0 18px; color: var(--muted); font-size: 12px; }
.typing .claude { color: var(--bot); font-weight: 600; }
.composer-wrap { padding: 0 18px 12px; position: relative; }
.composer { display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: #fff; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { flex: 1; border: 0; resize: none; font: inherit; max-height: 200px; outline: none; padding: 6px 4px; }
.composer .attach { font-size: 18px; color: var(--muted); }
.send { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 7px 16px; font-weight: 600; }
.send:disabled { opacity: .5; }
.hint { padding: 4px 4px 0; }
.upload-preview { padding: 6px 8px; margin-bottom: 6px; background: var(--bg-soft); border-radius: 8px; font-size: 13px; }
.mention-popup { position: absolute; bottom: 100%; left: 18px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 240px; max-height: 260px; overflow-y: auto; padding: 4px; z-index: 5; }
.mention-popup .opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.mention-popup .opt.sel, .mention-popup .opt:hover { background: var(--accent-soft); }
.drop-overlay { position: absolute; inset: 0; background: rgba(91,76,240,.12); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 18px; font-weight: 700; color: var(--accent); z-index: 10; pointer-events: none; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- 오른쪽 패널 ---------- */
.panel { width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); display: flex; flex-direction: column; background: #fff; }
.panel-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-body { flex: 1; overflow-y: auto; padding: 8px; }
.panel-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.panel-item:hover { background: var(--bg-soft); }
.panel-item .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel-group { font-size: 12px; font-weight: 700; color: var(--muted); padding: 10px 10px 4px; }
.member-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; }

/* ---------- 모달 ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 20; }
.modal-card { background: #fff; border-radius: 14px; width: min(460px, 92vw); max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-card header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
#modal-body { padding: 16px 18px; overflow-y: auto; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-weight: 600; margin-bottom: 4px; }
.field input[type=text], .field input[type=url] { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 18px; font-weight: 600; }
.btn.secondary { background: var(--bg-soft); color: var(--fg); border: 1px solid var(--border); }
.pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.pick-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.pick-row:hover { background: var(--bg-soft); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1e1c2a; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 30; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 40; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; }
