:root {
  --bg: #0e1320;
  --side: #131a2a;
  --chat: #0e1320;
  --panel: #1a2335;
  --bubble: #1e2a40;
  --bubble-me: #4f46e5;
  --ink: #e8edf6;
  --muted: #8b97ad;
  --line: #243049;
  --accent: #6366f1;
  --ok: #22c55e;
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native DARK. Opposite (light) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="light"]{
  --bg: #f4f4f6;
  --side: #4e6aac;
  --chat: #4e69b1;
  --panel: #f7f7f8;
  --bubble: #4d6ca4;
  --bubble-me: #5f57e7;
  --ink: #345185;
  --muted: #606e88;
  --line: rgba(0,0,0,0.10);
  --accent: #5457f0;
  --ok: #157c3b;
}












* { box-sizing: border-box; }
[hidden] { display: none !important; } /* 명시적 display가 [hidden]을 무력화하지 않도록 */
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans KR", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); height: 100vh; overflow: hidden;
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
input { font-family: inherit; }

/* Join modal */
.join {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 100;
  background:
    radial-gradient(700px 400px at 70% 10%, #1e2a52 0%, transparent 60%),
    var(--bg);
}
.join-card {
  background: var(--side); border: 1px solid var(--line); border-radius: 22px; padding: 32px 28px;
  width: 100%; max-width: 380px; text-align: center; box-shadow: 0 30px 70px -20px rgba(0,0,0,.6);
}
.join-logo { font-size: 40px; }
.join-card h1 { font-family: "Outfit", sans-serif; font-weight: 700; font-size: 24px; margin: 10px 0 6px; }
.join-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.avatar-pick { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.av {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 19px;
  cursor: pointer; border: 2px solid transparent; transition: transform .1s ease;
}
.av:hover { transform: scale(1.08); }
.av.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.nick-input {
  width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 12px; padding: 13px 15px; font-size: 16px; outline: none; text-align: center; margin-bottom: 12px;
}
.nick-input:focus { border-color: var(--accent); }
.join-tip { color: var(--muted); font-size: 12px; margin: 14px 0 0; }

.btn { font-family: "Outfit", sans-serif; font-weight: 700; cursor: pointer; border: none; border-radius: 12px; transition: transform .08s ease, filter .15s ease; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.block { width: 100%; padding: 13px; font-size: 15px; }

/* App layout */
.app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.logo { font-family: "Outfit", sans-serif; font-weight: 700; font-size: 16px; }
.close-side { display: none; background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.side-section { padding: 8px 10px; overflow-y: auto; }
.side-section h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 8px 6px; font-weight: 700; }
.count { color: var(--ok); }

.rooms { list-style: none; margin: 0; padding: 0; }
.room {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 9px; cursor: pointer;
  color: var(--muted); font-size: 14px; font-weight: 500; transition: background .12s ease, color .12s ease;
}
.room:hover { background: var(--panel); color: var(--ink); }
.room.active { background: var(--panel); color: var(--ink); }
.room .hash { opacity: .6; }
.room .badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }

.online { list-style: none; margin: 0; padding: 0; }
.on-item { display: flex; align-items: center; gap: 9px; padding: 6px 8px; font-size: 13.5px; }
.on-av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; flex-shrink: 0; }
.on-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.on-you { color: var(--muted); font-size: 11px; }
.on-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-left: auto; }

.me {
  margin-top: auto; padding: 12px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px;
}
.me .on-av { width: 32px; height: 32px; font-size: 16px; }
.me .me-name { font-weight: 700; font-size: 14px; }
.me .me-sub { font-size: 11px; color: var(--muted); }

/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.open-side { display: none; background: none; border: none; color: var(--ink); font-size: 18px; cursor: pointer; }
.ch-info { display: flex; flex-direction: column; }
.ch-name { font-family: "Outfit", sans-serif; font-weight: 700; font-size: 16px; }
.ch-desc { font-size: 12px; color: var(--muted); }

.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 3px; }
.day-sep { text-align: center; color: var(--muted); font-size: 11.5px; margin: 14px 0 8px; }

.msg { display: flex; gap: 10px; max-width: 78%; margin-top: 10px; animation: rise .18s ease backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg .m-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.msg .m-body { min-width: 0; }
.msg .m-name { font-size: 12px; color: var(--muted); margin: 0 0 3px 2px; font-weight: 600; }
.msg .m-bubble {
  background: var(--bubble); padding: 9px 13px; border-radius: 4px 14px 14px 14px; font-size: 14.5px;
  word-break: break-word; white-space: pre-wrap;
}
.msg .m-time { font-size: 10.5px; color: var(--muted); margin: 4px 0 0 2px; }
.msg.grouped { margin-top: 2px; }
.msg.grouped .m-av { visibility: hidden; }
.msg.grouped .m-name { display: none; }

/* mine */
.msg.mine { margin-left: auto; flex-direction: row-reverse; }
.msg.mine .m-bubble { background: var(--bubble-me); color: #fff; border-radius: 14px 4px 14px 14px; }
.msg.mine .m-name, .msg.mine .m-time { text-align: right; margin-left: 0; margin-right: 2px; }

/* bot */
.msg.bot .m-bubble { background: #14324a; border: 1px solid #1d4a6e; }

.typing { height: 20px; padding: 0 20px; font-size: 12.5px; color: var(--muted); font-style: italic; }

.composer { display: flex; gap: 10px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.msg-input {
  flex: 1; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 99px; padding: 12px 18px; font-size: 15px; outline: none;
}
.msg-input:focus { border-color: var(--accent); }
.send {
  width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--accent); color: #fff;
  font-size: 17px; cursor: pointer; flex-shrink: 0; transition: filter .15s ease, transform .08s ease;
}
.send:hover { filter: brightness(1.1); } .send:active { transform: scale(.94); }

/* Mobile */
@media (max-width: 700px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 30px 0 60px -20px rgba(0,0,0,.6);
  }
  body.side-open .sidebar { transform: translateX(0); }
  .close-side, .open-side { display: block; }
  .msg { max-width: 86%; }
}

/* i18n language switcher — 항상 다크 테마이므로 런타임 기본값을 어두운 톤으로 덮어쓴다. */
.chat-head .i18n-switch {
  margin-left: auto;
  --i18n-switch-bg: rgba(255, 255, 255, 0.07);
  --i18n-switch-border: rgba(255, 255, 255, 0.16);
  --i18n-switch-fg: rgba(255, 255, 255, 0.92);
  --i18n-switch-active-bg: rgba(99, 102, 241, 0.22);
  --i18n-switch-active-fg: var(--accent);
  --i18n-switch-menu-bg: var(--panel);
  --i18n-switch-menu-border: var(--line);
  --i18n-switch-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
