* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #1c2230;
  background: #f4f6fa;
}
#layout { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: 260px;
  background: #1f2733;
  color: #e7ecf3;
  padding: 16px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;            /* allow the inner list to scroll within the column */
}
#new-request {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #3d7eff;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 14px;
  flex-shrink: 0;           /* stays pinned at the top, never scrolls away */
}
#request-list {
  list-style: none;
  padding: 0;
  margin: 0;
  flex: 1;                  /* fill remaining height… */
  overflow-y: auto;         /* …and scroll when the list is long */
  min-height: 0;
}
#request-list li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 6px 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 4px;
  color: #c6cfdc;
}
#request-list li:hover { background: #2b3441; }
#request-list li.active { background: #3d7eff; color: #fff; }
#request-list .li-text { flex: 1; min-width: 0; cursor: pointer; }
#request-list .meta { display: block; font-size: 11px; opacity: 0.65; margin-top: 2px; }

#request-list .kebab {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0.6;
}
#request-list .kebab:hover { background: rgba(255, 255, 255, 0.14); opacity: 1; }
#request-list .row-menu {
  position: absolute;
  right: 6px;
  top: 100%;
  z-index: 30;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(10, 20, 40, 0.28);
  padding: 4px;
  min-width: 130px;
}
#request-list .row-menu .danger {
  width: 100%;
  background: transparent;
  color: #d6342c;
  text-align: left;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
}
#request-list .row-menu .danger:hover { background: #fceaea; }

#main { flex: 1; padding: 24px 32px; max-width: 860px; overflow-y: auto; }

/* --- chat panel (right) ------------------------------------------------------------------ */
#chat {
  width: 400px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e1e6ef;
}
#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg { max-width: 85%; padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-wrap: break-word; }
.msg .who { display: block; font-size: 11px; font-weight: 600; opacity: 0.7; margin-bottom: 2px; }
.msg.user { align-self: flex-end; background: #3d7eff; color: #fff; border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: #eef1f6; color: #1c2230; border-bottom-left-radius: 4px; }
#chat-empty { margin: auto; color: #8a93a3; font-size: 13px; text-align: center; }

/* typing indicator — three blinking dots while the agent forms a reply */
.msg.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.msg.typing .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #8a93a3;
  animation: chat-blink 1.4s infinite both;
}
.msg.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.msg.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

#chat-form {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid #e1e6ef;
  background: #fafbfd;
}
#chat-input {
  flex: 1;
  resize: none;
  max-height: 140px;
  border: 1px solid #cdd5e0;
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
}
/* send + mic share one row: identical height, vertically centred content */
#chat-send, #chat-mic {
  flex-shrink: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* voice input mic — square outline button matching the send button height */
#chat-mic {
  width: 38px;
  padding: 0;
  border: 1px solid #cdd5e0;
  border-radius: 10px;
  background: #fff;
  color: #4a5568;
  cursor: pointer;
}
#chat-mic svg { width: 19px; height: 19px; display: block; }
#chat-mic:hover:not(:disabled) { background: #f0f3f8; color: #1c2230; }
#chat-mic:disabled { opacity: 0.5; cursor: not-allowed; }
/* recording → red icon, pulsing ring, stays clickable to stop */
#chat-mic.recording {
  background: #ffe9e9; border-color: #ff5a5a; color: #e23b3b; opacity: 1; cursor: pointer;
  animation: chat-mic-pulse 1.2s infinite;
}
@keyframes chat-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 90, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(255, 90, 90, 0); }
}
/* transcribing → gentle blink */
#chat-mic.processing { opacity: 1; cursor: progress; animation: chat-mic-blink 1s ease-in-out infinite; }
@keyframes chat-mic-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

@media (max-width: 1100px) { #chat { width: 320px; } }

/* Equal-width cells filling the full content width (aligned with the card below) — 4 per row. */
#steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 22px; }
#steps .step {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  text-align: center;
  background: #e3e8f0;
  color: #6b7587;
  cursor: pointer;
  user-select: none;
}
@media (max-width: 560px) { #steps { grid-template-columns: repeat(2, 1fr); } }
#steps .step.active { background: #1f2733; color: #fff; }
#steps .step.done { background: #cfe7d6; color: #1c6b38; }
#steps .step.locked { opacity: 0.5; cursor: not-allowed; }

.card { background: #fff; border-radius: 12px; padding: 22px 24px; box-shadow: 0 1px 4px rgba(20,30,50,.07); }
.card h2 { margin: 0 0 16px; font-size: 19px; }

label { display: block; font-size: 13px; margin: 12px 0 4px; color: #45506280; color: #495062; }
input[type=text], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cdd5e0;
  border-radius: 8px;
  font-size: 14px;
}
textarea { resize: vertical; }
input.invalid, select.invalid { border-color: #d6342c; background: #fceaea; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; }
.row .narrow { flex: 0 0 auto; }

button {
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: #3d7eff;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
button.secondary { background: #e3e8f0; color: #2a3340; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.nav-buttons { display: flex; justify-content: space-between; margin-top: 22px; }

.result { padding: 10px 12px; border-radius: 8px; margin-top: 12px; font-size: 13px; }
.result.ok { background: #e3f5e9; color: #1c6b38; }
.result.bad { background: #fceaea; color: #a3262b; }

.candidate, .wh-option {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid #dde3ec; border-radius: 8px; margin-top: 8px; cursor: pointer;
}
.candidate.sel, .wh-option.sel { border-color: #3d7eff; background: #eff4ff; }
.candidate .sub, .wh-option .sub { font-size: 12px; color: #6b7587; }

.cardline { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #eef1f6; font-size: 14px; }
.cardline .lbl { color: #6b7587; }
.cardline .val { font-weight: 600; }

.emoji-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.emoji-opt { font-size: 22px; padding: 8px 12px; border: 2px solid #dde3ec; border-radius: 10px; cursor: pointer; }
.emoji-opt .lbl { font-size: 11px; display: block; text-align: center; }
.emoji-opt.sel { border-color: #3d7eff; background: #eff4ff; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
#toast.show { opacity: 1; }

#modal { position: fixed; inset: 0; background: rgba(20,28,40,.45); display: flex; align-items: center; justify-content: center; }
#modal.hidden { display: none; }
.modal-box { background: #fff; padding: 20px 22px; border-radius: 12px; width: 420px; max-width: 90vw; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.hint { font-size: 12px; color: #8a93a3; margin-top: 6px; }
.muted { color: #8a93a3; }
.hidden { display: none; }
