/* 웨스트 톡 — 어두운 금색 테마(접속기·설치 마법사와 같은 결), 채팅 종류는 원작 채팅 색 */
:root {
  --bg: #0b0b0f; --bg2: #101016; --panel: #15151c; --panel2: #1c1c25; --panel3: #24242f;
  --line: #2a2834; --line2: #3a3746; --text: #ece6d8; --dim: #a39a86; --faint: #6f695b;
  --gold: #d6b166; --gold-hi: #f7db9c; --gold-ink: #2a1d08; --red: #e8665f; --green: #74d383; --blue: #6fb5ff;
  --c-world: #7fd3ff; --c-clan: #9be38f; --c-dm: #ff9ad5; --c-group: #c7b3ff; --c-system: #8f8a7c;
  --mine: #3a3020; --mine-line: #5c4a26; --bubble: #1f1f29;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 14px; --rail: 68px; --side: 320px; --aside: 264px;
  --font: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --fs: 15px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #efebe3; --bg2: #e7e2d8; --panel: #fbfaf7; --panel2: #f3efe7; --panel3: #e9e3d7;
  --line: #ddd5c6; --line2: #cbc1ae; --text: #1d1a14; --dim: #6a6252; --faint: #968d7b;
  --gold: #9c7427; --gold-hi: #7a5716; --gold-ink: #fffaf0; --red: #c43d36; --green: #2f9446; --blue: #2e78c7;
  --c-world: #1e7fb8; --c-clan: #2e8a3a; --c-dm: #c23e7f; --c-group: #6a52c8; --c-system: #7d7768;
  --mine: #f3e4c2; --mine-line: #e0c98f; --bubble: #ffffff;
  --shadow: 0 10px 30px rgba(60, 45, 20, .18);
  color-scheme: light;
}
:root[data-size="small"] { --fs: 14px; }
:root[data-size="large"] { --fs: 17px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: var(--fs)/1.5 var(--font); height: var(--app-h, 100dvh); overflow: hidden;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-hi); }
.noscript { padding: 24px; text-align: center; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: rgba(214, 177, 102, .35); }
.scroll { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 8px; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

#app { height: 100%; }
.boot { display: grid; place-items: center; }
.boot-mark { width: 72px; height: 72px; border-radius: 18px; background: url(../icons/icon-192.png) center/cover;
  animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .55; transform: scale(.96); } }

/* ---------------------------------------------------------------- buttons, fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); font-weight: 600;
  white-space: nowrap; flex: none; }
.btn:hover { border-color: var(--gold); }
.btn.gold { background: linear-gradient(180deg, #f3d692, #b98c3f); color: #2a1d08; border-color: #8a6a2c; }
:root[data-theme="light"] .btn.gold { background: linear-gradient(180deg, #c89a45, #9c7427); color: #fffaf0; }
.btn.gold:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; color: var(--dim); }
.icon-btn:hover { background: var(--panel3); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .86em; color: var(--dim); }
.input { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line2);
  background: var(--bg2); color: var(--text); font-size: 16px; }
.input:focus { border-color: var(--gold); outline: none; }
.muted { color: var(--dim); }
.faint { color: var(--faint); }
.err { color: var(--red); min-height: 1.5em; font-size: .92em; }
.link { background: none; border: 0; color: var(--gold-hi); padding: 0; text-decoration: underline; }

/* ---------------------------------------------------------------- login, characters */
.gate { height: 100%; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  background: radial-gradient(1200px 600px at 50% -10%, rgba(214, 177, 102, .16), transparent 60%), var(--bg); overflow-y: auto; }
.card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px 24px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.brand-mark { width: 52px; height: 52px; border-radius: 14px; background: url(../icons/icon-192.png) center/cover; flex: none; }
.brand h1 { margin: 0; font-size: 1.45em; color: var(--gold-hi); letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; color: var(--dim); font-size: .9em; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.note { font-size: .84em; color: var(--faint); margin-top: 14px; line-height: 1.55; }
.char-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 14px; }
.char-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel2); text-align: left; }
.char-item:hover, .char-item.sel { border-color: var(--gold); }
.char-item .grow { flex: 1; min-width: 0; }
.char-item .name { font-weight: 700; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------------------------------------------------------------- avatars, badges, dots */
.av { position: relative; flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  font-weight: 700; font-size: .95em; color: var(--gold-hi); background: var(--panel3); border: 1.5px solid var(--line2); }
.av.sm { width: 32px; height: 32px; font-size: .8em; }
.av.lg { width: 64px; height: 64px; font-size: 1.3em; }
.av.k0 { color: #ffd766; } .av.k1 { color: #ff9f7a; } .av.k2 { color: #9be38f; } .av.k3 { color: #8fc8ff; }
.av.k4 { color: #d6a6ff; } .av.k5 { color: #ff7d7d; } .av.k6 { color: #7fe7e0; }
.av.world { color: var(--c-world); border-color: var(--c-world); }
.av.clan { color: var(--c-clan); border-color: var(--c-clan); }
.av.dm { border-color: var(--c-dm); }
.av.group { color: var(--c-group); border-color: var(--c-group); }
.dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--panel); background: var(--faint); }
.dot.game { background: var(--green); } .dot.msg { background: var(--blue); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--gold); color: #2a1d08;
  font-size: .78em; font-weight: 800; display: inline-grid; place-items: center; }
:root[data-theme="light"] .badge { color: #fffaf0; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .76em;
  border: 1px solid var(--line2); color: var(--dim); white-space: nowrap; }
.tag.game { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.tag.msg { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 45%, transparent); }
.tag.lord { color: var(--gold-hi); border-color: var(--gold); }

/* ---------------------------------------------------------------- the shell */
.shell { display: grid; height: 100%; grid-template-columns: var(--rail) var(--side) minmax(0, 1fr);
  padding-left: var(--safe-l); padding-right: var(--safe-r); }
.shell.members-open { grid-template-columns: var(--rail) var(--side) minmax(0, 1fr) var(--aside); }
.rail { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: calc(14px + var(--safe-t)) 0 14px;
  background: var(--bg2); border-right: 1px solid var(--line); }
.rail .brand-mark { width: 40px; height: 40px; border-radius: 11px; margin-bottom: 10px; }
.rail-btn { position: relative; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px;
  border: 0; background: transparent; color: var(--faint); }
.rail-btn:hover { color: var(--text); background: var(--panel2); }
.rail-btn.on { color: var(--gold-hi); background: var(--panel2); }
.rail-btn .badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; font-size: .68em; padding: 0 5px; }
.rail .spacer { flex: 1; }
.side { display: flex; flex-direction: column; min-width: 0; background: var(--panel); border-right: 1px solid var(--line); }
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.aside { display: none; flex-direction: column; min-width: 0; background: var(--panel); border-left: 1px solid var(--line); }
.members-open .aside { display: flex; }
.pane-head { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: calc(8px + var(--safe-t)) 12px 8px 16px;
  border-bottom: 1px solid var(--line); }
.pane-head h2 { margin: 0; font-size: 1.15em; flex: 1; min-width: 0; }
.pane-body { flex: 1; min-height: 0; }
.section-title { padding: 14px 16px 6px; font-size: .78em; font-weight: 700; color: var(--faint); letter-spacing: .04em; }
.empty { padding: 40px 24px; text-align: center; color: var(--faint); }
.empty .big { font-size: 2em; margin-bottom: 8px; }

/* ---------------------------------------------------------------- lists */
.list-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border: 0; border-left: 3px solid transparent;
  background: transparent; text-align: left; color: var(--text); min-height: 64px; }
.list-item:hover { background: var(--panel2); }
.list-item.on { background: var(--panel2); border-left-color: var(--gold); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .top { display: flex; align-items: baseline; gap: 8px; }
.list-item .title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .time { font-size: .76em; color: var(--faint); flex: none; }
.list-item .sub { display: flex; align-items: center; gap: 8px; margin-top: 1px; }
.list-item .preview { flex: 1; min-width: 0; color: var(--dim); font-size: .9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-world .title { color: var(--c-world); } .k-clan .title { color: var(--c-clan); }
.k-dm .title { color: var(--c-dm); } .k-group .title { color: var(--c-group); }

/* ---------------------------------------------------------------- conversation */
.conv { display: flex; flex-direction: column; height: 100%; min-height: 0; position: relative; }
.main-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--faint); padding: 24px; }
.main-empty .brand-mark { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px; opacity: .85; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.conv-head .sub { font-size: .8em; color: var(--dim); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-head .titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-head .titles b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05em; }
.conv-head.k-world b { color: var(--c-world); } .conv-head.k-clan b { color: var(--c-clan); }
.conv-head.k-dm b { color: var(--c-dm); } .conv-head.k-group b { color: var(--c-group); }
.back { display: none; }
.log { flex: 1; min-height: 0; padding: 12px 14px 6px; display: flex; flex-direction: column; }
.log > .spacer-top { flex: 1; }
.loader { text-align: center; padding: 8px; color: var(--faint); font-size: .85em; }
.day { align-self: center; margin: 14px 0 8px; padding: 3px 12px; border-radius: 999px; background: var(--panel2);
  color: var(--dim); font-size: .78em; }
.unread-line { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--gold); font-size: .78em; }
.unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--gold) 50%, transparent); }
.sys { align-self: center; max-width: 90%; margin: 6px 0; color: var(--c-system); font-size: .82em; text-align: center; }
.sys.local { color: var(--c-dm); }
.msg { display: flex; gap: 10px; margin-top: 10px; max-width: min(760px, 100%); }
.msg.cont { margin-top: 3px; }
.msg.cont .av { visibility: hidden; height: 0; }
.msg .body { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.msg .who { display: flex; align-items: baseline; gap: 6px; margin: 0 0 3px 2px; font-size: .84em; }
.msg .who b { font-weight: 700; cursor: pointer; }
.msg .who .meta { color: var(--faint); font-size: .92em; }
.k-world .msg .who b { color: var(--c-world); } .k-clan .msg .who b { color: var(--c-clan); }
.k-dm .msg .who b { color: var(--c-dm); } .k-group .msg .who b { color: var(--c-group); }
.bubble-row { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.bubble { padding: 8px 12px; border-radius: 4px 14px 14px 14px; background: var(--bubble); border: 1px solid var(--line);
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-width: min(560px, 76vw); }
.msg .stamp { font-size: .7em; color: var(--faint); flex: none; padding-bottom: 2px; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .body { align-items: flex-end; }
.msg.me .bubble-row { flex-direction: row-reverse; }
.msg.me .bubble { background: var(--mine); border-color: var(--mine-line); border-radius: 14px 4px 14px 14px; }
.msg.me .av, .msg.me .who { display: none; }
.msg.pending .bubble { opacity: .6; }
.msg.failed .bubble { border-color: var(--red); }
.msg .retry { font-size: .74em; color: var(--red); background: none; border: 0; padding: 0 2px; }
.typing { min-height: 22px; padding: 0 16px; font-size: .8em; color: var(--dim); }
.jump { position: absolute; right: 18px; bottom: 90px; z-index: 5; box-shadow: var(--shadow); }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px calc(10px + var(--safe-b)); border-top: 1px solid var(--line);
  background: var(--panel); position: relative; }
.composer textarea { flex: 1; min-height: 44px; max-height: 132px; resize: none; padding: 11px 14px; border-radius: 22px;
  border: 1px solid var(--line2); background: var(--bg2); color: var(--text); font-size: 16px; line-height: 1.4;
  overflow-y: hidden; scrollbar-width: thin; }
.composer textarea:focus { outline: none; border-color: var(--gold); }
.composer .send { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, #f3d692, #b98c3f); color: #2a1d08; }
.composer .send[disabled] { opacity: .45; }
.composer.locked { justify-content: center; color: var(--dim); font-size: .9em; padding-top: 16px; }
.hints { position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; z-index: 10; }
.hints button { display: flex; gap: 10px; width: 100%; padding: 10px 14px; border: 0; background: transparent; text-align: left; }
.hints button:hover, .hints button.on { background: var(--panel3); }
.hints code { color: var(--gold-hi); font-family: inherit; font-weight: 700; }
.emoji-pop { position: absolute; left: 10px; bottom: calc(100% + 6px); width: min(320px, calc(100% - 20px)); display: grid;
  grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 14px; box-shadow: var(--shadow); z-index: 10; }
.emoji-pop button { border: 0; background: transparent; font-size: 22px; height: 38px; border-radius: 8px; }
.emoji-pop button:hover { background: var(--panel3); }

/* ---------------------------------------------------------------- news, settings */
.cards { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.panel-card { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel-card h3 { margin: 0 0 8px; font-size: 1em; color: var(--gold-hi); }
.status { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.status .lamp { width: 12px; height: 12px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px rgba(0, 0, 0, .15); }
.status .lamp.online { background: var(--green); box-shadow: 0 0 12px var(--green); }
.status .lamp.odd { background: #e6b64c; } .status .lamp.offline { background: var(--red); }
.notice { padding: 12px 0; border-top: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.notice:first-of-type { border-top: 0; padding-top: 0; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; color: var(--dim); min-height: 36px; }
.seg button.on { background: var(--panel3); color: var(--gold-hi); font-weight: 700; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; border: 1px solid var(--line2); background: var(--bg2); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--faint); transition: transform .15s, background .15s; }
.switch.on { background: color-mix(in srgb, var(--gold) 30%, var(--bg2)); border-color: var(--gold); }
.switch.on::after { transform: translateX(20px); background: var(--gold-hi); }
.add-row { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.add-row .input { min-height: 44px; }

/* ---------------------------------------------------------------- sheets, menus, toasts */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .5); display: grid; place-items: center;
  padding: 16px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: min(420px, 100%); max-height: min(640px, 90vh); display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--line2); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 10px 18px; }
.sheet-head h3 { margin: 0; flex: 1; font-size: 1.08em; }
.sheet-body { padding: 4px 18px 18px; overflow-y: auto; }
.profile { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding-top: 6px; }
.profile .nm { font-size: 1.25em; font-weight: 800; }
.profile .tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.actions { display: grid; gap: 8px; margin-top: 16px; }
.menu { position: fixed; z-index: 60; min-width: 190px; background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border: 0;
  border-radius: 10px; background: transparent; text-align: left; }
.menu button:hover { background: var(--panel3); }
.menu button.danger { color: var(--red); }
.toasts { position: fixed; z-index: 80; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, calc(100% - 24px)); }
.toast { pointer-events: auto; padding: 11px 16px; border-radius: 12px; background: var(--panel3); border: 1px solid var(--line2);
  box-shadow: var(--shadow); animation: rise .18s ease-out; display: flex; gap: 12px; align-items: center; }
.toast.bad { border-color: var(--red); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.offline-bar { padding: 6px 12px; text-align: center; font-size: .82em; background: #5a2a24; color: #ffd9d4; }
:root[data-theme="light"] .offline-bar { background: #f6d6d2; color: #7a1f18; }

/* ---------------------------------------------------------------- phones */
.tabbar { display: none; }
@media (max-width: 899px) {
  .shell, .shell.members-open { grid-template-columns: minmax(0, 1fr); }
  .rail, .aside, .members-open .aside { display: none; }
  .side { border-right: 0; padding-bottom: calc(62px + var(--safe-b)); }
  .shell[data-view="room"] .side { display: none; }
  .shell[data-view="list"] .main { display: none; }
  .back { display: inline-grid; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(60px + var(--safe-b));
    padding: 4px var(--safe-r) var(--safe-b) var(--safe-l); background: var(--bg2); border-top: 1px solid var(--line); }
  .shell[data-view="room"] .tabbar { display: none; }
  .tab { position: relative; flex: 1; border: 0; background: transparent; color: var(--faint); display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px; font-size: .72em; }
  .tab.on { color: var(--gold-hi); }
  .tab .badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: .68em; padding: 0 5px; }
  .scrim { align-items: end; padding: 0; }
  .sheet { width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0; padding-bottom: var(--safe-b); animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } }
  .bubble { max-width: 78vw; }
  .jump { bottom: calc(96px + var(--safe-b)); }
  .toasts { bottom: calc(78px + var(--safe-b)); }
}
@media (min-width: 900px) and (max-width: 1199px) {
  :root { --side: 290px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
