:root{
  --bg:#F1EBE3;
  --bg2:#EAE3F3;
  --panel:#FFFDFA;
  --ink:#2B2730;
  --sub:#6F6879;
  --muted:#9A93A3;
  --line:rgba(43,39,48,.09);
  --lav:#7561B4;
  --lav-2:#927FCB;
  --lav-soft:#EEE8FB;
  --gold:#B9852C;
  --radius:20px;
  --font:-apple-system,BlinkMacSystemFont,"Apple SD Gothic Neo","Pretendard","Malgun Gothic","Noto Sans KR",system-ui,sans-serif;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0;font-family:var(--font);color:var(--ink);
  background:
    radial-gradient(120% 70% at 100% 0%, rgba(146,127,203,.16), transparent 60%),
    radial-gradient(90% 60% at 0% 100%, rgba(185,133,44,.09), transparent 55%),
    var(--bg);
  min-height:100dvh;
}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}

/* ── gate ── */
.gate{min-height:100dvh;display:grid;place-items:center;padding:24px}
.gate-card{
  width:min(400px,100%);background:var(--panel);border:1px solid var(--line);
  border-radius:26px;padding:34px 26px 26px;box-shadow:0 24px 60px -30px rgba(43,39,48,.4);
  text-align:center;
}
.gate-mark{display:flex;gap:5px;justify-content:center;margin-bottom:18px}
.gate-mark span{width:9px;height:9px;border-radius:50%;background:var(--lav);opacity:.35}
.gate-mark span:nth-child(2){opacity:.65}
.gate-mark span:nth-child(3){opacity:1}
.gate-card h1{font-size:22px;margin:0 0 6px;letter-spacing:-.02em}
.gate-sub{color:var(--muted);font-size:13px;margin:0 0 24px}
.gate-card form{display:flex;flex-direction:column;gap:10px}
.gate-card input{
  height:50px;border-radius:14px;border:1px solid var(--line);background:#FAF7F2;
  padding:0 16px;font-size:16px;font-family:inherit;color:var(--ink);outline:none;
}
.gate-card input:focus{border-color:var(--lav);background:#fff;box-shadow:0 0 0 4px rgba(117,97,180,.1)}
.btn-primary{
  height:50px;border:0;border-radius:14px;background:var(--lav);color:#fff;font-size:15px;
  font-weight:600;font-family:inherit;letter-spacing:-.01em;cursor:pointer;transition:transform .12s,filter .12s;
}
.btn-primary:active{transform:scale(.985);filter:brightness(.96)}
.btn-primary[disabled]{opacity:.55}
.gate-err{color:#C24757;font-size:13px;min-height:18px;margin:12px 0 0}
.gate-foot{color:var(--muted);font-size:11.5px;margin:8px 0 0;letter-spacing:.01em}

/* ── app shell ── */
.app{
  display:flex;flex-direction:column;height:100dvh;max-width:760px;margin:0 auto;
  background:linear-gradient(180deg, rgba(255,253,250,.86), rgba(255,253,250,.62));
  border-inline:1px solid var(--line);
}
.topbar{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:calc(14px + env(safe-area-inset-top)) 18px 12px;
  background:rgba(246,241,234,.82);backdrop-filter:blur(14px);border-bottom:1px solid var(--line);
  position:sticky;top:0;z-index:20;
}
.topbar-title{display:flex;align-items:center;gap:10px}
.live-dot{width:8px;height:8px;border-radius:50%;background:#3FA97A;box-shadow:0 0 0 4px rgba(63,169,122,.14)}
.topbar h1{font-size:16px;margin:0;letter-spacing:-.02em}
.topbar p{margin:1px 0 0;font-size:11.5px;color:var(--muted)}
.icon-btn{background:transparent;border:0;padding:8px;border-radius:10px;color:var(--sub);cursor:pointer}
.icon-btn:active{background:rgba(43,39,48,.06)}

/* member chips */
.members{display:flex;gap:8px;overflow-x:auto;padding:11px 16px 12px;border-bottom:1px solid var(--line);scrollbar-width:none}
.members::-webkit-scrollbar{display:none}
.chip{
  display:flex;align-items:center;gap:7px;flex:0 0 auto;border:1px solid var(--line);
  background:rgba(255,255,255,.7);border-radius:999px;padding:5px 12px 5px 6px;
  font-size:12.5px;font-family:inherit;color:var(--sub);cursor:pointer;transition:.16s;
}
.chip .dot{width:20px;height:20px;border-radius:50%;display:grid;place-items:center;font-size:10px;font-weight:700;color:#fff}
.chip.on{background:#fff;border-color:rgba(117,97,180,.35);color:var(--ink);box-shadow:0 2px 10px -6px rgba(43,39,48,.4)}
.chip.off{opacity:.42}
.chip.me{cursor:default;background:var(--ink);color:#fff;border-color:var(--ink)}
.chip.me .dot{background:rgba(255,255,255,.18)}

/* ── list ── */
.list{
  flex:1;overflow-y:auto;padding:16px 14px 8px;display:flex;flex-direction:column;gap:14px;
  scroll-behavior:smooth;overscroll-behavior:contain;
}
.day-sep{text-align:center;margin:2px 0 4px}
.day-sep span{font-size:11px;color:var(--muted);background:rgba(255,255,255,.72);padding:4px 12px;border-radius:999px}
.intro{
  background:rgba(255,255,255,.62);border:1px solid var(--line);border-radius:18px;padding:14px 16px;
  color:var(--sub);font-size:12.8px;line-height:1.68;
}
.intro-k{color:var(--lav);font-size:11px;letter-spacing:.08em;text-transform:uppercase;margin:0 0 6px;font-weight:600}
.intro b{color:var(--ink);font-weight:600}
.intro p{margin:0}

.row{display:flex;gap:9px;align-items:flex-start;max-width:100%;animation:pop .22s ease-out}
@keyframes pop{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.row.me{flex-direction:row-reverse}
.avatar{
  width:30px;height:30px;border-radius:11px;display:grid;place-items:center;flex:0 0 auto;
  font-size:11px;font-weight:700;color:#fff;margin-top:16px;letter-spacing:-.02em;
}
.avatar.hidden{visibility:hidden}
.bubble-wrap{display:flex;flex-direction:column;gap:4px;max-width:calc(100% - 44px);min-width:0}
.who{font-size:11.5px;color:var(--muted);padding-left:2px;display:flex;align-items:center;gap:6px}
.who .role{color:var(--muted);opacity:.75}
.who.hidden{visibility:hidden}
.bubble{
  background:var(--panel);border:1px solid var(--line);border-radius:5px 18px 18px 18px;
  padding:11px 14px;font-size:14.3px;line-height:1.62;color:var(--ink);white-space:pre-wrap;word-break:break-word;
  box-shadow:0 6px 18px -16px rgba(43,39,48,.6);
}
.row.me .bubble{
  background:linear-gradient(160deg,var(--lav),#5F4C9E);color:#fff;border:0;border-radius:18px 5px 18px 18px;
  box-shadow:0 10px 24px -16px rgba(95,76,158,.85);
}
.row.err .bubble{background:#FCF2F3;border-color:#F0D6DA;color:#9C3A47;font-size:12.8px}
.bubble .tag{
  display:inline-block;font-size:10px;font-weight:700;letter-spacing:.06em;color:var(--lav);
  background:var(--lav-soft);border-radius:6px;padding:2px 6px;margin-bottom:6px;vertical-align:1px;
}
.meta{font-size:10.5px;color:var(--muted);padding:0 3px;display:flex;gap:7px}
.row.me .meta{justify-content:flex-end}
.notice{align-self:center;font-size:11.5px;color:var(--sub);background:rgba(255,255,255,.8);border:1px solid var(--line);padding:6px 14px;border-radius:999px;text-align:center;max-width:86%}

/* typing */
.typing{display:flex;align-items:center;gap:8px;padding:2px 22px 8px;color:var(--muted);font-size:11.5px}
.dots{display:inline-flex;gap:3px}
.dots i{width:5px;height:5px;border-radius:50%;background:var(--lav);opacity:.4;animation:blink 1.1s infinite}
.dots i:nth-child(2){animation-delay:.18s}
.dots i:nth-child(3){animation-delay:.36s}
@keyframes blink{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}

/* quick + composer */
.quick{display:flex;gap:7px;overflow-x:auto;padding:0 14px 9px;scrollbar-width:none}
.quick::-webkit-scrollbar{display:none}
.quick button{
  flex:0 0 auto;font-family:inherit;font-size:12.3px;color:var(--lav);background:var(--lav-soft);
  border:1px solid rgba(117,97,180,.16);border-radius:999px;padding:8px 13px;cursor:pointer;
}
.quick button:active{filter:brightness(.96)}
.composer{
  display:flex;align-items:flex-end;gap:8px;padding:9px 14px calc(12px + env(safe-area-inset-bottom));
  background:rgba(246,241,234,.9);backdrop-filter:blur(12px);border-top:1px solid var(--line);
}
.composer textarea{
  flex:1;resize:none;border:1px solid var(--line);background:var(--panel);border-radius:20px;
  padding:11px 15px;font-size:14.5px;line-height:1.45;font-family:inherit;color:var(--ink);
  max-height:132px;outline:none;
}
.composer textarea:focus{border-color:rgba(117,97,180,.4);box-shadow:0 0 0 4px rgba(117,97,180,.08)}
.composer textarea::placeholder{color:#B0A9B8;font-size:13px}
.send{
  width:42px;height:42px;flex:0 0 auto;border:0;border-radius:50%;background:var(--lav);color:#fff;
  display:grid;place-items:center;cursor:pointer;transition:.15s;
}
.send:active{transform:scale(.94)}
.send[disabled]{opacity:.45}

/* sheet */
.sheet-backdrop{position:fixed;inset:0;background:rgba(30,26,36,.34);backdrop-filter:blur(2px);z-index:40}
.sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:41;background:var(--panel);
  border-radius:24px 24px 0 0;padding:10px 18px calc(20px + env(safe-area-inset-bottom));
  max-width:760px;margin:0 auto;box-shadow:0 -20px 60px -30px rgba(0,0,0,.5);
}
.sheet-grip{width:38px;height:4px;border-radius:99px;background:var(--line);margin:2px auto 14px}
.sheet h2{font-size:14px;margin:0 0 10px;color:var(--sub);font-weight:600;letter-spacing:-.01em}
.sheet-rows{display:flex;flex-direction:column}
.sheet-row{
  display:flex;align-items:center;justify-content:space-between;gap:10px;background:transparent;
  border:0;border-bottom:1px solid var(--line);padding:15px 2px;font-family:inherit;font-size:14px;
  color:var(--ink);cursor:pointer;text-align:left;
}
.sheet-row em{font-style:normal;font-size:12px;color:var(--muted)}
.sheet-row.danger{color:#B23A48}
.sheet-note{font-size:11.5px;color:var(--muted);line-height:1.6;margin:14px 0 0}

.context-card{
  position:fixed;inset:12px;max-width:640px;margin:auto;background:var(--panel);border-radius:20px;
  display:flex;flex-direction:column;overflow:hidden;box-shadow:0 30px 80px -40px #000;z-index:42;
}
.context-card header{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;border-bottom:1px solid var(--line)}
.context-card h2{font-size:14px;margin:0}
.ctx-body{overflow:auto;padding:14px 16px 22px}
.ctx-body pre{white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:1.65;color:var(--sub);margin:0}

.toast{
  position:fixed;left:50%;bottom:calc(88px + env(safe-area-inset-bottom));transform:translateX(-50%);
  background:rgba(43,39,48,.92);color:#fff;font-size:12.5px;padding:9px 16px;border-radius:999px;z-index:50;
  max-width:82%;text-align:center;
}

@media (min-width:600px){
  .list{padding:22px 22px 10px}
  .bubble{font-size:14.6px}
  .app{height:100dvh;box-shadow:0 0 60px -40px rgba(43,39,48,.6)}
}
