:root{
  --bg:#16121a; --bg2:#201a25; --card:#2a2230; --line:#3a3040;
  --text:#f1e9ef; --muted:#9d8f9a; --rose:#ff6f91; --rose2:#ff9eb4; --rose-dim:#4a2a36;
  --bubble-ai:#2f2636; --bubble-me:#ff6f91;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;background:#0d0a10;color:var(--text);font-family:'Noto Sans KR',sans-serif}
.hidden{display:none!important}
a{color:var(--rose2)}
button{font:inherit;cursor:pointer;border:none;border-radius:12px;padding:10px 16px;color:inherit;background:none}
button:disabled{opacity:.45;cursor:default}
input,select,textarea{font:inherit;color:var(--text);background:var(--bg2);border:1px solid var(--line);border-radius:12px;padding:11px 13px;outline:none;width:100%}
input:focus,select:focus,textarea:focus{border-color:var(--rose)}
textarea{resize:none}
.primary{background:var(--rose);color:#fff;font-weight:700}
.ghost{border:1px solid var(--line);color:var(--muted)}
.wide{width:100%}
.err{color:#ff8a8a;font-size:13px;margin:0;min-height:1em;white-space:pre-wrap}
.icon{padding:6px 10px;font-size:20px;color:var(--muted)}
.icon:hover{color:var(--text)}

#app{max-width:520px;margin:0 auto;height:100dvh;background:var(--bg);position:relative;overflow:hidden}
.screen{height:100%;display:flex;flex-direction:column}
.center{justify-content:center;padding:24px}

/* 로그인 */
.card{display:flex;flex-direction:column;gap:10px}
.logo{font-size:44px;text-align:center}
.card h1{font-family:'Gowun Batang',serif;text-align:center;margin:0;color:var(--rose2)}
.sub{text-align:center;color:var(--muted);margin:0 0 10px;font-size:14px}
.tabs{display:flex;background:var(--bg2);border-radius:12px;padding:4px}
.tab{flex:1;padding:8px;color:var(--muted)}
.tab.active{background:var(--card);color:var(--text);font-weight:700}

/* 홈 */
.top{display:flex;justify-content:space-between;align-items:center;padding:16px 18px 10px}
.top h2{margin:0;font-size:22px}
.user{font-size:12px;color:var(--muted)}
.pane{flex:1;overflow-y:auto;padding:4px 14px 90px}
.hint{color:var(--muted);font-size:13px;line-height:1.6;margin:4px 4px 12px}
.list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.list li{display:flex;align-items:center;gap:12px;padding:12px;background:var(--bg2);border-radius:16px;cursor:pointer}
.list li:hover{background:var(--card)}
.li-main{flex:1;min-width:0}
.li-title{font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.li-sub{font-size:12px;color:var(--muted);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.li-side{font-size:12px;color:var(--muted);text-align:right;white-space:nowrap}
.li-side .h{color:var(--rose);font-weight:700}
.empty{justify-content:center;color:var(--muted);font-size:14px;cursor:default!important;flex-direction:column;padding:30px!important;text-align:center;line-height:1.7}
.badge{font-size:11px;background:var(--rose-dim);color:var(--rose2);padding:2px 7px;border-radius:8px;margin-left:6px}

.avatar{flex:none;width:48px;height:48px;border-radius:50%;display:grid;place-items:center;font-size:24px;
  background:linear-gradient(135deg,#5b2a45,#2b2440)}
.avatar.sm{width:36px;height:36px;font-size:18px}
.avatar.lg{width:72px;height:72px;font-size:38px}

.search{margin-bottom:10px}
.chips{display:flex;gap:6px;overflow-x:auto;padding-bottom:10px;scrollbar-width:none}
.chips button{flex:none;padding:6px 12px;border-radius:20px;background:var(--bg2);color:var(--muted);font-size:13px}
.chips button.active{background:var(--rose);color:#fff}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.sc{background:var(--bg2);border-radius:16px;padding:14px;cursor:pointer;display:flex;flex-direction:column;gap:6px;min-height:150px}
.sc:hover{background:var(--card)}
.sc .e{font-size:30px}
.sc .t{font-weight:700;font-size:14px;line-height:1.35}
.sc .h{font-size:12px;color:var(--muted);line-height:1.5;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.tag{display:inline-block;font-size:11px;color:var(--rose2);background:var(--rose-dim);padding:2px 8px;border-radius:8px;width:fit-content}

.bottom{position:absolute;bottom:0;left:0;right:0;display:flex;background:rgba(22,18,26,.96);border-top:1px solid var(--line);padding-bottom:env(safe-area-inset-bottom)}
.bottom button{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;padding:10px 0;font-size:20px;color:var(--muted);border-radius:0}
.bottom button span{font-size:11px}
.bottom button.active{color:var(--rose)}

/* 시트(모달) */
.sheet{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:flex-end;justify-content:center;z-index:10}
.sheet-body{position:relative;background:var(--bg);width:min(520px,100%);max-height:92dvh;overflow-y:auto;border-radius:22px 22px 0 0;padding:22px 18px 28px;display:flex;flex-direction:column;gap:10px;animation:up .25s}
@keyframes up{from{transform:translateY(40px);opacity:0}}
.close{position:absolute;top:10px;right:10px}
.sheet h3{margin:0;font-size:19px;line-height:1.35}
.sc-head{display:flex;gap:14px;align-items:center;padding-right:30px}
.hook{margin:4px 0;color:var(--rose2);font-family:'Gowun Batang',serif;line-height:1.6}
.info{display:grid;grid-template-columns:auto 1fr;gap:6px 12px;margin:0;font-size:13px;background:var(--bg2);padding:12px;border-radius:14px}
.info dt{color:var(--muted)} .info dd{margin:0;line-height:1.5}
.opening{font-size:13px;color:var(--muted);font-style:italic;line-height:1.6;border-left:3px solid var(--rose-dim);padding-left:10px}
.lbl{font-size:13px;color:var(--muted);display:flex;flex-direction:column;gap:6px}
.seg{display:flex;gap:6px}
.seg button{flex:1;background:var(--bg2);color:var(--muted);font-size:14px}
.seg button.active{background:var(--rose-dim);color:var(--rose2);font-weight:700;outline:1px solid var(--rose)}
.row2{display:flex;gap:8px}.row2>*{flex:1}
.check{display:flex;gap:8px;align-items:center;font-size:14px;color:var(--muted)}
.check input{width:auto}

/* 채팅방 */
.chat-top{position:relative;display:flex;align-items:center;gap:8px;padding:8px 6px;border-bottom:1px solid var(--line);background:var(--bg)}
.chat-title{flex:1;min-width:0;display:flex;flex-direction:column}
.chat-title b{font-size:15px}
.chat-title small{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.aff{font-size:13px;color:var(--rose);font-weight:700;padding:4px 8px;background:var(--rose-dim);border-radius:10px;transition:transform .3s}
.aff.bump{transform:scale(1.25)}
.menu{position:absolute;right:8px;top:52px;background:var(--card);border:1px solid var(--line);border-radius:14px;display:flex;flex-direction:column;z-index:5;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,.4)}
.menu button{text-align:left;padding:12px 16px;font-size:14px;border-radius:0}
.menu button:hover{background:var(--bg2)}

#messages{flex:1;overflow-y:auto;padding:16px 12px 10px;display:flex;flex-direction:column;gap:6px}
.turn{display:flex;flex-direction:column;gap:6px;margin-bottom:8px;animation:fade .3s}
@keyframes fade{from{opacity:0;transform:translateY(4px)}}
.ai-row{display:flex;gap:8px;align-items:flex-start}
.ai-col{display:flex;flex-direction:column;gap:6px;min-width:0;max-width:84%}
.ai-name{font-size:12px;color:var(--muted);margin-left:2px}
.narr{font-size:14px;line-height:1.7;color:#c9b8c6;font-style:italic;padding:2px 4px}
.ai .narr{}
.bub{padding:10px 14px;border-radius:4px 18px 18px 18px;background:var(--bubble-ai);line-height:1.6;font-size:15px;white-space:pre-wrap;word-break:break-word;width:fit-content}
.bub i{color:#c9b8c6}
.me{align-items:flex-end}
.me .bub{background:var(--bubble-me);color:#fff;border-radius:18px 4px 18px 18px;max-width:84%}
.me .bub i{color:#ffe3ea}
.me .narr{text-align:right;max-width:84%;color:#d9a8b6}
.typing::after{content:'●●●';letter-spacing:2px;font-size:10px;color:var(--muted);animation:blink 1s infinite}
@keyframes blink{50%{opacity:.3}}
.sys{align-self:center;font-size:12px;color:var(--muted);background:var(--bg2);padding:6px 12px;border-radius:12px;text-align:center;line-height:1.6}
.sys.err{color:#ff8a8a}

.composer{display:flex;gap:6px;align-items:flex-end;padding:8px 8px calc(8px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--bg)}
.composer textarea{border-radius:20px;padding:10px 14px;max-height:120px;line-height:1.5}
.star{font-size:18px;padding:9px}
.send{width:40px;height:40px;border-radius:50%;padding:0;background:var(--rose);color:#fff;font-size:20px;font-weight:700;flex:none}

/* ===== 오픈채팅 ===== */
.bottom button{font-size:19px}
.pill{font-size:13px;padding:6px 12px;border-radius:16px;background:var(--rose-dim);color:var(--rose2);white-space:nowrap}
.danger{color:#ff8a8a;border-color:#5a2a2a}
.checks{display:flex;flex-direction:column;gap:6px;max-height:210px;overflow-y:auto}
.checks label{display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--bg2);border-radius:12px;font-size:14px;cursor:pointer}
.checks input{width:auto}
.checks small{color:var(--muted);margin-left:auto;font-size:11px;white-space:nowrap}
.checks .none{color:var(--muted);font-size:13px;padding:10px 4px;line-height:1.6}
.list.mini li{padding:8px 10px;cursor:default}
.list.mini .avatar{width:34px;height:34px;font-size:17px}
.ai-tag{font-size:10px;color:var(--muted);border:1px solid var(--line);border-radius:6px;padding:0 4px;margin-left:5px;vertical-align:middle}

.talk{flex:1;overflow-y:auto;padding:14px 12px 6px;display:flex;flex-direction:column;gap:3px}
.t-row{display:flex;gap:8px;align-items:flex-start;margin-top:8px;animation:fade .25s}
.t-row.cont{margin-top:0}
.t-row.cont .avatar{visibility:hidden;height:0}
.t-row.cont .t-name{display:none}
.t-col{display:flex;flex-direction:column;gap:3px;max-width:78%;min-width:0}
.t-name{font-size:12px;color:var(--muted);margin-left:2px}
.t-bub{padding:8px 12px;border-radius:4px 16px 16px 16px;background:var(--bubble-ai);font-size:15px;line-height:1.5;white-space:pre-wrap;word-break:break-word;width:fit-content}
.t-row.human .t-bub{background:#3a3344}
.t-row.me{flex-direction:row-reverse}
.t-row.me .t-col{align-items:flex-end}
.t-row.me .t-bub{background:var(--bubble-me);color:#fff;border-radius:16px 4px 16px 16px}
.t-sys{align-self:center;font-size:12px;color:var(--muted);background:var(--bg2);padding:4px 12px;border-radius:12px;margin:8px 0 2px;text-align:center}
.t-sys.err{color:#ff8a8a}
.typing-line{min-height:20px;padding:0 16px 2px;font-size:12px;color:var(--muted)}

.sc .tg{font-size:11px;color:var(--rose2);margin-top:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
