.robot-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 24px 88px;
  color: #213144;
}
.robot-tabs {
  display: flex;
  gap: 10px;
  border-bottom: 1px solid #dce4e9;
  margin-bottom: 18px;
}
.robot-tabs button {
  border: 0;
  background: none;
  padding: 12px 14px;
  color: #607286;
  cursor: pointer;
}
.robot-tabs button[aria-current='page'] {
  color: #0d6f67;
  border-bottom: 3px solid #0d8a78;
  font-weight: 700;
}
.robot-chat,
.robot-owner-panel {
  background: #fff;
  border: 1px solid #e0e7eb;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 6px 24px #203b5010;
}
.robot-history {
  min-height: 260px;
  max-height: 55vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px;
}
.robot-empty {
  color: #697b8d;
  margin: auto;
  text-align: center;
}
.robot-exchange {
  border: 1px solid #e3e9ee;
  border-radius: 14px;
  overflow: hidden;
}
.robot-question {
  background: #f6f8fa;
  padding: 14px 18px;
}
.robot-question small {
  float: right;
  color: #77889a;
}
.robot-answer {
  padding: 16px 18px;
}
.robot-exchange p {
  margin: 8px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.robot-answer small {
  display: block;
  color: #6d7e8e;
  margin: 10px 0;
}
.robot-answer button {
  margin-top: 8px;
}
.robot-ask {
  border-top: 1px solid #e3e9ee;
  margin-top: 20px;
  padding-top: 18px;
}
.robot-ask label,
.robot-owner-panel label {
  display: block;
  font-weight: 600;
  margin: 0 0 8px;
}
.robot-ask textarea,
.robot-owner-panel input:not([type='checkbox']),
.robot-owner-panel textarea,
.robot-owner-panel select,
.robot-correction textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cbd7df;
  border-radius: 10px;
  padding: 11px;
  font: inherit;
  color: inherit;
  background: #fff;
}
.robot-ask > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}
.robot-ask small {
  color: #728294;
}
.robot-correction {
  background: #f8fafb;
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
}
.robot-correction label {
  display: block;
  margin-bottom: 10px;
}
.robot-owner-panel h3 {
  margin: 0 0 8px;
}
.robot-owner-panel > p {
  color: #697b8d;
}
.robot-owner-panel form {
  display: grid;
  gap: 12px;
  margin: 20px 0;
  padding: 20px;
  border: 1px solid #e2e9ed;
  border-radius: 14px;
}
.robot-owner-panel fieldset {
  border: 1px solid #dce6e9;
  border-radius: 10px;
  padding: 12px;
}
.robot-owner-panel fieldset label {
  display: inline-flex;
  align-items: center;
  margin: 8px 16px 8px 0;
  gap: 6px;
  font-weight: 400;
}
.robot-owner-panel fieldset small {
  display: block;
  color: #708397;
}
.robot-owner-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.robot-owner-actions select {
  max-width: 180px;
}
.robot-cards {
  display: grid;
  gap: 12px;
}
.robot-card {
  border: 1px solid #e0e8ed;
  border-radius: 12px;
  padding: 16px;
  margin: 10px 0;
}
.robot-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.robot-card header span,
.robot-card small {
  color: #6f8291;
}
.robot-card p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.robot-card button {
  margin: 8px 8px 0 0;
}
.robot-review-day {
  margin: 24px 0;
}
.robot-review-day h3 {
  border-bottom: 1px solid #e2e9ed;
  padding-bottom: 8px;
}
.robot-error {
  padding: 12px;
  border-radius: 8px;
  background: #fff0ef;
  color: #a33126;
  margin-top: 14px;
}
@media (max-width: 680px) {
  .robot-page {
    padding: 12px 12px 90px;
  }
  .robot-head {
    padding: 18px;
    display: block;
  }
  .robot-head h2 {
    font-size: 23px;
  }
  .robot-offline {
    display: inline-block;
    margin-top: 14px;
  }
  .robot-chat,
  .robot-owner-panel {
    padding: 14px;
  }
  .robot-ask > div {
    align-items: stretch;
    flex-direction: column;
  }
  .robot-ask button {
    width: 100%;
  }
  .robot-tabs {
    overflow: auto;
    white-space: nowrap;
  }
}
@media (max-width: 760px) {
  .robot-head h2 {
    display: none;
  }
}

#robotKnowledgeForm fieldset label {
  width: auto;
  white-space: nowrap;
  display: inline-flex;
  gap: 8px;
  margin: 8px 20px 8px 0;
}
#robotKnowledgeForm input[type='checkbox'] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  flex: 0 0 18px;
  margin: 0;
}
#robotKnowledgeStatus {
  align-self: center;
  overflow-wrap: anywhere;
}
/* Compact chat keeps the composer beside the conversation on phones. */
.robot-page.is-chat {
  height: var(--robot-height, 75vh);
  padding: 8px 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  max-width: 960px;
}
.robot-page.is-chat .robot-tabs {
  flex-shrink: 0;
  margin-bottom: 8px;
}
.robot-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #f5f7f8;
  border-radius: 14px;
}
.robot-history {
  flex: 1;
  min-height: 0;
  max-height: none;
  padding: 16px;
  gap: 22px;
}
.robot-exchange {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 0;
  overflow: visible;
  flex-shrink: 0;
}
.robot-exchange time {
  text-align: center;
  color: #85919c;
  font-size: 11px;
}
.robot-question,
.robot-answer {
  max-width: 85%;
  width: fit-content;
  padding: 10px 14px;
  box-sizing: border-box;
  border-radius: 15px;
  float: none;
}
.robot-question {
  align-self: flex-end;
  background: #167c70;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.robot-answer {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e4e9ed;
  border-bottom-left-radius: 4px;
}
.robot-answer > strong {
  font-size: 12px;
  color: #587570;
}
.robot-exchange p {
  margin: 3px 0;
  line-height: 1.65;
}
.robot-answer .robot-correct {
  padding: 2px 0;
  border: 0;
  background: none;
  font-size: 12px;
  color: #7b8a96;
  min-height: 0;
}
.robot-answer summary {
  font-size: 12px;
  color: #687c89;
  cursor: pointer;
}
.robot-answer small {
  font-size: 12px;
}
.robot-chat .robot-ask {
  display: flex;
  flex-shrink: 0;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e3e9ee;
}
.robot-chat .robot-ask textarea {
  flex: 1;
  min-height: 44px;
  max-height: 112px;
  resize: none;
  line-height: 22px;
  padding: 10px 12px;
  font-size: 16px;
}
.robot-chat .robot-ask button {
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 10px 16px;
  flex-shrink: 0;
}
.robot-pending {
  color: #6d7e8e;
  font-size: 13px;
}
.robot-empty {
  font-size: 14px;
}
.robot-page.is-chat .robot-error {
  flex-shrink: 0;
  margin: 4px 0;
  padding: 6px;
}

/* A top-layer conversation: app navigation is inert until the user returns. */
body.robot-chat-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}
dialog.robot-chat-fullscreen {
  position: fixed;
  inset: 0 auto auto 0;
  width: 100%;
  max-width: none;
  max-height: none;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
  background: #f5f7f8;
  color: #213144;
  overflow: hidden;
}
dialog.robot-chat-fullscreen[open] {
  display: flex;
  flex-direction: column;
}
.robot-chat-fullscreen::backdrop {
  background: #f5f7f8;
}
.robot-chat-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
  min-height: 56px;
  padding: env(safe-area-inset-top, 0px) 12px 0;
  background: #f7f8fa;
  border-bottom: 1px solid #dce4e9;
}
.robot-chat-header strong {
  font-size: 18px;
}
.robot-chat-header .robot-chat-back {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: #213144;
  font: inherit;
  cursor: pointer;
}
.robot-chat-back span:first-child {
  font-size: 32px;
  line-height: 1;
}
.robot-chat-fullscreen .robot-page.is-chat {
  width: 100%;
  max-width: none;
  height: auto;
  min-height: 0;
  flex: 1;
  margin: 0;
  padding: 0;
}
.robot-chat-fullscreen .robot-tabs {
  display: none;
}
.robot-chat-fullscreen .robot-chat {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.robot-chat-fullscreen .robot-history {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px max(16px, calc((100% - 900px) / 2));
}
.robot-chat-fullscreen .robot-ask {
  padding: 10px max(12px, calc((100% - 900px) / 2)) max(10px, env(safe-area-inset-bottom, 0px));
}
.robot-chat-fullscreen .robot-ask textarea {
  min-width: 0;
}
