
:root{
  --bg:#f7f7f8;
  --panel:#ffffff;
  --ink:#111112;
  --muted:#6b7280;
  --line:#e5e7eb;
  --brand:#1f6feb;
  --success:#10b981;
  --accent:#f59e0b;
  --shadow:0 8px 30px rgba(0,0,0,.06);
  
  /* iOS Variables for chat-demo.html */
  --ios-blue: #007AFF;
  --ios-gray: #8E8E93;
  --ios-light-gray: #F2F2F7;
  --ios-separator: #C6C6C8;
  --message-received: #E5E5EA;
  --message-sent: #007AFF;
  --text-primary: #000000;
  --text-secondary: #8E8E93;
  --background: #FFFFFF;
}

*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);
  font:14.5px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;}

.root{display:grid;grid-template-columns:300px 1fr;height:100vh;}

/* iOS Chat Container (for chat-demo.html) */
.chat-container{
  height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 500px;
  margin: 0 auto;
  background: var(--background);
}

/* Sidebar */
.sidebar{background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column;min-width:260px;}
.sidebar-header{display:flex;align-items:center;justify-content:space-between;padding:14px 14px;border-bottom:1px solid var(--line);}
.brand{font-weight:700;letter-spacing:.2px;}
.icon-btn{border:1px solid var(--line);background:#fff;border-radius:8px;padding:6px 8px;cursor:pointer}
.sidebar-controls{padding:12px;border-bottom:1px solid var(--line);}
.btn{display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--line);border-radius:10px;
  padding:8px 12px;background:#fff;cursor:pointer;transition:transform .02s ease;}
.btn:hover{transform:translateY(-1px)}
.btn.primary{background:var(--brand);color:#fff;border-color:var(--brand)}
.section{padding:6px 8px}
.section-title{color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.08em;margin:12px 8px 6px}
.threads{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px;}

.thread{display:grid;grid-template-columns:auto 1fr auto;gap:10px;align-items:center;padding:10px;border-radius:10px;cursor:pointer;}
.thread:hover{background:#f3f4f6}
.thread.active{background:#eef2ff}
.thread .title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.thread .meta{font-size:12px;color:var(--muted)}
.dot{width:10px;height:10px;border-radius:50%;background:var(--success)}
.platform{width:18px;height:18px;display:grid;place-items:center;border-radius:6px;background:#f3f4f6;border:1px solid var(--line)}

/* Main */
.main{display:grid;grid-template-rows:auto 1fr auto;height:100%}
.topbar{display:flex;align-items:center;justify-content:space-between;background:var(--panel);border-bottom:1px solid var(--line);padding:10px 14px;position:sticky;top:0;z-index:10}
.title{font-weight:700}
.selected-label{color:var(--muted);font-size:12px;margin-right:6px}
.avatar-btn{width:36px;height:36px;border-radius:50%;overflow:hidden;border:1px solid var(--line);background:#fff;padding:0;cursor:pointer;display:grid;place-items:center}
.avatar-btn img{width:100%;height:100%;object-fit:cover;border-radius:50%}
.persona-menu{position:absolute;right:14px;top:58px;width:300px;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);padding:10px;z-index:20}
.persona-menu .menu-head{font-size:12px;color:var(--muted);margin:6px}
.persona-menu ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.persona-row{display:flex;gap:10px;align-items:center;padding:8px;border-radius:8px;cursor:pointer}
.persona-row:hover{background:#f3f4f6}
.persona-row img{width:28px;height:28px;border-radius:50%;object-fit:cover}
.hidden{display:none}

/* Stream */
.stream{padding:16px;overflow:auto;background:linear-gradient(#fafafb,#f7f7f8);}
.empty{margin:80px auto;text-align:center;color:var(--muted)}
.empty-icon{font-size:32px;margin-bottom:6px}
.row{display:flex;margin:8px 0}
.row.left{justify-content:flex-start}
.row.right{justify-content:flex-end}
.bubble{max-width:70%;background:#fff;border:1px solid var(--line);padding:10px 12px;border-radius:14px;white-space:pre-wrap;box-shadow:0 1px 0 rgba(0,0,0,.03)}
.bubble.agent{background:#eef6ff;border-color:#cfe3ff}
.meta-line{font-size:12px;color:var(--muted);margin:2px 4px}
.typing{display:inline-flex;gap:4px}
.dot-typing{width:6px;height:6px;background:#cbd5e1;border-radius:50%;animation:bounce 1.2s infinite}
.dot-typing:nth-child(2){animation-delay:.2s}
.dot-typing:nth-child(3){animation-delay:.4s}
@keyframes bounce{
  0%,80%,100%{transform:translateY(0);opacity:.4}
  40%{transform:translateY(-5px);opacity:1}
}

/* Composer */
.composer{display:grid;grid-template-columns:1fr auto;grid-template-areas:"badge badge" "input actions";gap:8px;padding:12px;border-top:1px solid var(--line);background:var(--panel);align-items:end}
.badge{grid-area:badge;align-self:center;background:#d1fae5;color:#065f46;border:1px solid #a7f3d0;padding:4px 8px;border-radius:8px;font-size:12px}
.input{grid-area:input;width:100%;border:1px solid var(--line);border-radius:12px;padding:10px 12px;resize:vertical;min-height:46px;max-height:120px;font:inherit;line-height:1.4;overflow-y:auto;word-wrap:break-word}
.actions{grid-area:actions;display:flex;gap:8px;align-self:end}

/* Modal */
.modal{position:fixed;inset:0;display:grid;place-items:center;background:rgba(0,0,0,.3)}
.modal-card{width:420px;background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);overflow:hidden}
.modal-header{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;border-bottom:1px solid var(--line)}
.modal-title{font-weight:700}
.modal-content{padding:10px 12px;display:flex;flex-direction:column;gap:12px}
.field{display:flex;flex-direction:column;gap:6px}
.field input,.field select{border:1px solid var(--line);border-radius:8px;padding:8px 10px;font:inherit}
.hint{color:var(--muted)}
.modal-footer{padding:10px 12px;border-top:1px solid var(--line);display:flex;justify-content:flex-end}
