:root{
  --bg:#faf9f5;
  --sidebar-bg:#f4f3ee;
  --panel:#ffffff;
  --border:#e7e5dd;
  --border-soft:#ecebe4;
  --text:#1f1e1b;
  --text-mid:#54514a;
  --text-mut:#8d8a80;
  --text-faint:#a8a59a;
  --hover:#ecebe4;
  --active:#e6e4db;
  --accent:#c8623a;
  --accent-orange:#d8794f;
  --radius:14px;
  --font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue","Apple SD Gothic Neo","Malgun Gothic",sans-serif;
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:var(--font);
  color:var(--text);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  overflow:hidden;
}
svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
button{font-family:inherit;cursor:pointer;background:none;border:none;color:inherit}

.app{display:flex;flex-direction:column;height:100vh}

/* ── 타이틀바 ── */
.titlebar{
  height:46px;flex:0 0 46px;
  display:flex;align-items:center;justify-content:space-between;
  padding:0 14px;background:var(--bg);
  user-select:none;
}
.tb-left,.tb-right{display:flex;align-items:center;gap:4px}
.tb-btn{
  width:32px;height:32px;border-radius:8px;
  display:flex;align-items:center;justify-content:center;
  color:var(--text-mid);
}
.tb-btn:hover{background:var(--hover)}
.tb-btn svg{width:19px;height:19px}
.tb-btn.win svg{width:16px;height:16px;stroke-width:1.6}
.tb-btn.close:hover{background:#e8543f;color:#fff}

/* ── 셸 ── */
.shell{flex:1;display:flex;min-height:0}

/* ── 사이드바 ── */
.sidebar{
  width:236px;flex:0 0 236px;
  background:var(--sidebar-bg);
  border-right:1px solid var(--border-soft);
  display:flex;flex-direction:column;
  padding:6px 8px 8px;
}

.seg{
  display:flex;gap:2px;
  background:var(--active);
  border-radius:9px;padding:2px;margin-bottom:8px;
}
.seg-btn{
  flex:1;display:flex;align-items:center;justify-content:center;gap:5px;
  height:27px;border-radius:7px;font-size:12.5px;font-weight:500;
  color:var(--text-mid);
}
.seg-btn svg{width:13px;height:13px;stroke-width:1.9}
.seg-btn.active{background:var(--panel);color:var(--text);box-shadow:0 1px 2px rgba(0,0,0,.05)}
.seg-btn:not(.active):hover{color:var(--text)}

.nav{display:flex;flex-direction:column;gap:1px}
.nav-item{
  display:flex;align-items:center;gap:10px;
  height:31px;padding:0 9px;border-radius:7px;
  font-size:13px;color:var(--text-mid);text-align:left;
}
.nav-item svg{width:16px;height:16px;flex:0 0 16px;color:var(--text-mut)}
.nav-item span{flex:1}
.nav-item:hover{background:var(--hover);color:var(--text)}
.nav-item.active{background:var(--active);color:var(--text);font-weight:500}
.nav-item.active svg{color:var(--text-mid)}

.sb-spacer{flex:1;min-height:14px}

.account{
  display:flex;align-items:center;gap:9px;
  height:40px;padding:0 7px;border-radius:9px;
  border-top:1px solid var(--border-soft);
}
.account:hover{background:var(--hover)}
.avatar{
  width:23px;height:23px;flex:0 0 23px;border-radius:50%;
  background:#3b3a35;color:#fff;font-size:11px;font-weight:600;
  display:flex;align-items:center;justify-content:center;
}
.acc-name{flex:1;text-align:left;font-size:13px;font-weight:500;color:var(--text)}
.chev{width:14px;height:14px;color:var(--text-mut)}
.acc-dl{width:15px;height:15px;color:var(--text-mut)}

/* ── 메인 ── */
.main{
  flex:1;min-width:0;
  display:flex;align-items:center;justify-content:center;
  background-color:var(--bg);
  background-image:radial-gradient(rgba(120,116,104,.18) 1px,transparent 1px);
  background-size:22px 22px;
  background-position:center;
  padding:40px;
}
.hero{
  width:100%;max-width:760px;
  display:flex;flex-direction:column;align-items:center;
  margin-top:-40px;
}
.spark{color:var(--accent);margin-bottom:18px}
.spark svg{width:42px;height:42px;stroke-width:1.4;fill:var(--accent);stroke:var(--accent)}
h1{font-size:34px;font-weight:600;letter-spacing:-.02em;color:var(--text);text-align:center}
.sub{margin-top:12px;font-size:14.5px;color:var(--text-mut)}
.sub a{color:var(--text-mid);text-decoration:underline;text-underline-offset:2px}

.composer{width:100%;max-width:720px;margin-top:34px}
.composer-box{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:0 1px 3px rgba(0,0,0,.04);
  padding:20px 20px 12px;
  min-height:128px;
  display:flex;flex-direction:column;
}
.composer-input{
  flex:1;width:100%;
  font-family:inherit;font-size:15px;line-height:1.5;color:var(--text);
  background:transparent;border:none;outline:none;resize:none;
  padding:0 0 14px;
  min-height:24px;max-height:260px;overflow-y:auto;
}
.composer-input::placeholder{color:var(--text-faint)}
.composer-foot{display:flex;align-items:center;justify-content:space-between}
.cc-btn{
  width:34px;height:34px;border-radius:9px;
  display:flex;align-items:center;justify-content:center;
  color:var(--text-mid);border:1px solid var(--border);
}
.cc-btn:hover{background:var(--hover)}
.cc-btn.mic{border:none}
.cc-btn.mic:hover{background:var(--hover)}

.composer-controls{
  display:flex;align-items:center;gap:10px;
  margin-top:14px;
}
.chip{
  display:flex;align-items:center;gap:7px;
  height:36px;padding:0 13px;border-radius:10px;
  font-size:13.5px;color:var(--text-mid);
  background:transparent;border:1px solid transparent;
}
.chip svg{width:16px;height:16px;color:var(--text-mut)}
.chip .chip-chev{width:14px;height:14px}
.chip:hover{background:var(--hover);color:var(--text)}
.chip.model{margin-left:auto}

/* ── 채팅 메시지 ── */
.messages{display:none}
.hero.chatting{
  margin-top:0;
  height:100%;
  max-width:860px;
  justify-content:flex-end;
}
.hero.chatting .messages{
  display:flex;flex-direction:column;gap:14px;
  width:100%;flex:1;overflow-y:auto;
  padding:24px 4px 8px;
}
.msg{display:flex}
.msg.user{justify-content:flex-end}
.msg.assistant{justify-content:flex-start}
.bubble{
  max-width:78%;
  font-size:14.5px;line-height:1.62;
  padding:11px 15px;border-radius:14px;
  white-space:normal;word-break:break-word;
}
.msg.user .bubble{
  background:#2f2e2a;color:#fff;border-bottom-right-radius:5px;
}
.msg.assistant .bubble{
  background:var(--panel);border:1px solid var(--border);
  color:var(--text);border-bottom-left-radius:5px;
}
.bubble .err{color:#c0392b}
.bubble.typing::after{
  content:'●●●';letter-spacing:2px;color:var(--text-faint);
  animation:blink 1.2s infinite;
}
@keyframes blink{0%,100%{opacity:.3}50%{opacity:1}}
.hero.chatting .composer{margin-top:10px;padding-bottom:8px}

@media (max-width:720px){
  .sidebar{display:none}
  h1{font-size:26px}
  .bubble{max-width:88%}
}
