:root {
  --bg: #f5f3ee; --card: #ffffff; --ink: #1d2327; --muted: #667079; --line: #e3dfd5; --soft: #faf8f3;
  --accent: #0e6f66; --accent-dark: #0a5750; --accent-soft: #e4f2ef; --me: #dcefe9;
  --warn-bg: #fff6e3; --warn-ink: #8a5300; --bad: #a3271f; --bad-bg: #fdecea;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Segoe UI", "Arial Hebrew", Arial, sans-serif; font-size: 16px; line-height: 1.55; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
.hidden { display: none !important; }

/* buttons: only a real action is solid */
.btn { border: 1px solid var(--accent); color: var(--accent); background: #fff; border-radius: 9px; padding: 7px 16px; cursor: pointer; }
.btn:hover { background: var(--accent-soft); }
.btn.solid { background: var(--accent); color: #fff; font-weight: 600; }
.btn.solid:hover { background: var(--accent-dark); }
.btn.quiet { border-color: var(--line); color: var(--muted); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; font-size: 14px; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; width: 40px; height: 40px; cursor: pointer; font-size: 20px; line-height: 1; color: var(--muted); flex: none; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* layout */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.side { background: var(--soft); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { padding: 16px 14px 10px; }
.brand { font-weight: 700; font-size: 18px; margin-bottom: 12px; }
.chats { flex: 1; overflow-y: auto; padding: 4px 8px; }
.chat-link { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 9px 10px; border-radius: 9px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-link:hover { background: #efece4; }
.chat-link.on { background: var(--accent-soft); font-weight: 600; }
.chat-link small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.side-bottom { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.whoami { color: var(--muted); font-size: 13.5px; flex: 1 1 100%; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; }
.top { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.top #menu { display: none; }
.title { margin: 0; font-size: 18px; font-weight: 600; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 9px 20px; font-size: 14.5px; }

/* messages */
.msgs { flex: 1; overflow-y: auto; padding: 22px 20px 10px; display: flex; flex-direction: column; gap: 14px; }
.inner { width: 100%; max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 440px; }
.empty b { display: block; color: var(--ink); font-size: 20px; margin-bottom: 6px; }
.m { max-width: 82%; white-space: pre-wrap; overflow-wrap: anywhere; }
.m.me { align-self: flex-end; background: var(--me); border-radius: 14px 14px 14px 4px; padding: 9px 14px; }
.m.bot { align-self: flex-start; }
.m.bot.err { color: var(--bad); }
.files { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; white-space: normal; }
.file { background: #fff; border: 1px solid #c9ddd7; border-radius: 10px; padding: 6px 10px; font-size: 14px; max-width: 100%; }
.file small { color: var(--muted); display: block; font-size: 12px; }
.file audio { display: block; margin-top: 6px; height: 34px; max-width: 260px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; align-self: flex-start; }
.typing { align-self: flex-start; color: var(--muted); font-size: 14.5px; }
.typing::after { content: "..."; animation: dots 1.2s steps(4, end) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }

/* the box that waits for a click */
.card { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; width: min(480px, 100%); white-space: normal; }
.card h4 { margin: 0 0 8px; font-size: 16.5px; }
.rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 18px; font-size: 14.5px; margin: 0 0 12px; }
.rows dt { color: var(--muted); }
.rows dd { margin: 0; }
.card .warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 7px 10px; font-size: 14px; margin-bottom: 10px; }
.card .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.card .tiny { color: var(--muted); font-size: 13px; margin-top: 8px; }
.card .state { font-size: 14.5px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); }
.card .state.bad { background: var(--bad-bg); color: var(--bad); }
.card.off { opacity: .6; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* composer */
.composer { border-top: 1px solid var(--line); background: var(--card); padding: 10px 20px 14px; }
.composer .row, .composer .chips { max-width: 780px; margin: 0 auto; }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; max-height: 180px; min-height: 40px; outline: none; background: #fff; }
.composer textarea:focus { border-color: var(--accent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chips:empty { margin: 0; }
.chip { background: var(--accent-soft); border-radius: 16px; padding: 3px 6px 3px 12px; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 2px 4px; }
.drop { outline: 2px dashed var(--accent); outline-offset: -8px; }

/* login + settings */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(400px, 100%); }
.panel h1 { margin: 0 0 4px; font-size: 24px; }
.panel p { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; background: #fff; outline: none; }
.field input:focus { border-color: var(--accent); }
.code input { letter-spacing: 8px; font-size: 22px; text-align: center; direction: ltr; }
.msg { font-size: 14.5px; margin-top: 10px; min-height: 22px; color: var(--muted); }
.msg.bad { color: var(--bad); }
.wrap { max-width: 900px; margin: 0 auto; padding: 26px 20px 60px; }
.wrap h1 { font-size: 26px; margin: 0 0 4px; }
.wrap h2 { font-size: 19px; margin: 34px 0 10px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.sub { color: var(--muted); font-size: 14.5px; margin: 0 0 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: start; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }
.inline .field { margin: 0; flex: 1 1 150px; }
.pill { display: inline-block; font-size: 12.5px; border-radius: 12px; padding: 1px 9px; background: var(--accent-soft); color: var(--accent); }
.pill.off { background: #eee; color: var(--muted); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.grow { overflow-x: auto; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 0 0 auto; width: min(300px, 86vw); z-index: 5; transform: translateX(105%); transition: transform .18s; box-shadow: 0 0 30px rgba(0, 0, 0, .15); }
  .side.open { transform: none; }
  .top #menu { display: block; }
  .m { max-width: 94%; }
}
