:root {
  --bg: #0f0f14; --panel: #181820; --border: #2a2a36; --text: #e9e9f0; --muted: #8a8a9a;
  --accent: #e0245e; --accent-2: #ff4f83; --user: #2a2340; --bot: #1f1f2a; --error: #4a1d24;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.app { max-width: 860px; height: 100vh; margin: 0 auto; display: flex; flex-direction: column; padding: 0 16px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 20px; margin: 0; }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 12px 0; }
.controls label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; flex: 1; min-width: 150px; }
select, textarea { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit; }
select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.direction { flex: 1; min-width: 150px; padding: 9px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; font-weight: 600; }
.direction span { color: var(--accent); margin: 0 6px; }

.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 0; }
.empty { color: var(--muted); text-align: center; margin: auto; max-width: 420px; }
.msg { position: relative; max-width: 80%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bot); border: 1px solid var(--border); border-bottom-left-radius: 4px; padding-bottom: 28px; }
.msg.typing { color: var(--muted); font-style: italic; padding-bottom: 10px; }
.msg.error { align-self: center; background: var(--error); font-size: 14px; }
.copy { position: absolute; right: 8px; bottom: 6px; background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; }
.copy:hover { color: var(--accent-2); }

.composer { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; resize: vertical; min-height: 56px; max-height: 240px; }

.btn { border: none; border-radius: 8px; padding: 10px 18px; font: inherit; cursor: pointer; color: var(--text); }
.btn.primary { background: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary:disabled { opacity: .5; cursor: wait; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13px; }

.foot { font-size: 12px; color: var(--muted); text-align: center; padding-bottom: 10px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 10; }
.overlay[hidden] { display: none; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; max-width: 420px; text-align: center; }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

@media (max-width: 600px) { .msg { max-width: 92%; } }
