:root {
  color-scheme: light;
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app { width: 100%; height: 100%; margin: 0; }

body {
  overflow: hidden;
  background: #111 url("./assets/original/background.jpg") center / cover no-repeat;
}

button, textarea { font: inherit; }
button { touch-action: manipulation; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(20, 120, 232, .4);
  outline-offset: 2px;
}

.app-shell { min-height: 100%; position: relative; }
.chat-center {
  width: 100%;
  min-height: 100%;
}
#panel[data-screen="chat"] {
  height: 100%;
  overflow: hidden;
  background: #eef0f2;
}
#panel[data-screen="chat"] .conversation { width: 100%; height: 100%; overflow: hidden; }

/* Quiz stays available as the lightweight entry flow. */
.conversation { height: 100%; overflow: auto; padding: 12px 0 24px; }
.row { display: flex; align-items: flex-start; gap: 6px; margin: 10px; }
.row.me { justify-content: flex-end; }
.avatar { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; background: #fff; }
.bubble {
  position: relative;
  max-width: min(76%, 560px);
  min-height: 20px;
  padding: 8px 15px;
  border: 1px solid #ededed;
  border-radius: 5px;
  color: #000;
  background: rgba(245, 245, 245, .92);
  font-size: 16px;
  font-weight: 700;
  line-height: 21px;
  word-break: break-all;
}
.row.me .bubble { background: #95ec69; font-weight: 400; }
.options { display: grid; gap: 10px; margin-top: 12px; }
.option, .reset-button {
  border: 0;
  border-radius: 20px;
  padding: 10px 20px;
  color: #fff;
  background: #f56c6c;
  font-size: 14px;
}
.reset-button { margin-top: 10px; background: #1478e8; }

/* Same-page support chat replica. */
.support-window {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f3f3f3;
}
.support-header {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 50px;
  flex: 0 0 50px;
  padding: 0 15px;
  color: #fff;
  background: #1478e8;
}
.support-header-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.support-online-dot {
  width: 10px;
  height: 10px;
  margin-left: -14px;
  margin-top: 24px;
  border: 2px solid #1478e8;
  border-radius: 50%;
  background: #36c66b;
}
.support-header-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.support-body { display: flex; min-height: 0; flex: 1; background: #fff; }
.support-chat-column {
  display: flex;
  width: 620px;
  min-width: 0;
  flex: 1 1 620px;
  flex-direction: column;
}
.support-messages {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 13px 18px;
  background: #f3f3f3;
  scrollbar-color: #b9b9b9 #f3f3f3;
  scrollbar-width: thin;
}
.support-messages::-webkit-scrollbar { width: 7px; }
.support-messages::-webkit-scrollbar-thumb { border-radius: 8px; background: #b9b9b9; }
.message-timestamp { margin: 8px 0 11px; color: #999; font-size: 11px; text-align: center; }
.support-message { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; }
.local-message { flex-direction: row-reverse; }
.message-avatar { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%; object-fit: cover; }
.message-content {
  display: flex;
  max-width: calc(100% - 44px);
  min-width: 0;
  align-items: flex-start;
  flex-direction: column;
}
.local-message .message-content { align-items: flex-end; }
.message-sender { margin: -1px 0 2px; color: #161616; font-size: 12px; line-height: 17px; }
.message-card {
  position: relative;
  max-width: 100%;
  padding: 8px 11px;
  border: 1px solid #e6e6e6;
  border-radius: 3px;
  color: #222;
  background: #fff;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.agent-message .message-card::before {
  position: absolute;
  top: 11px;
  left: -6px;
  width: 10px;
  height: 10px;
  border-bottom: 1px solid #e6e6e6;
  border-left: 1px solid #e6e6e6;
  background: #fff;
  content: "";
  transform: rotate(45deg);
}
.local-message .message-card { border-color: #9cde79; background: #a7e888; }
.local-message .message-card::after {
  position: absolute;
  top: 11px;
  right: -6px;
  width: 10px;
  height: 10px;
  border-top: 1px solid #9cde79;
  border-right: 1px solid #9cde79;
  background: #a7e888;
  content: "";
  transform: rotate(45deg);
}
.link-card { width: min(504px, 100%); padding: 9px 20px 14px; text-align: center; }
.link-card p { margin: 0 0 7px; }
.link-welcome { font-weight: 500; }
.link-url { overflow-wrap: anywhere; color: #1478e8; }
.link-reminder { margin-top: 14px !important; color: #111; font-size: 13px; }
.copy-link-button { border: 0; border-radius: 3px; padding: 5px 10px; color: #fff; background: #1478e8; font-size: 13px; }
.image-message { width: min(292px, 100%); padding: 14px; overflow: hidden; }
.image-message .reply-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}
.reply-image[role="button"] { cursor: zoom-in; }
.reply-image[role="button"]:focus-visible {
  outline: 2px solid #1478e8;
  outline-offset: 3px;
}
.audio-message {
  width: 316px;
  padding: 8px 10px;
  border: 1px solid #e6e6e6;
  background: #fff;
}
.message-audio {
  display: block;
  width: 100%;
  min-width: 0;
  height: 34px;
}
.quick-replies { width: min(504px, 100%); }
.quick-reply-title { margin: 0 0 5px; font-weight: 700; }
.quick-reply-list { display: grid; gap: 1px; }
.quick-reply-button {
  border: 0;
  padding: 3px 0;
  color: #1478e8;
  background: transparent;
  text-align: left;
}
.quick-reply-button:hover { text-decoration: underline; }
.quick-reply-button:disabled { color: #999; text-decoration: none; }
.support-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 63px;
  flex: 0 0 63px;
  padding: 9px 12px;
  border-top: 1px solid #ddd;
  background: #fff;
}
.support-input {
  min-width: 0;
  height: 33px;
  flex: 1;
  resize: none;
  border: 1px solid #d9dce2;
  border-radius: 3px;
  padding: 6px 12px;
  line-height: 20px;
}
.emoji-control, .plus-control { width: 28px; border: 0; color: #777; background: transparent; font-size: 21px; line-height: 30px; }
.support-send { border: 0; border-radius: 3px; padding: 8px 14px; color: #fff; background: #1478e8; }
.support-profile {
  display: flex;
  width: 270px;
  flex: 0 0 270px;
  align-items: center;
  flex-direction: column;
  padding: 42px 18px;
  border-left: 1px solid #e5e5e5;
  background: #fff;
  text-align: center;
}
.support-profile-avatar { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; }
.support-profile-name { margin-top: 18px; color: #333; font-size: 16px; }
.support-profile-status { margin-top: 7px; color: #35b96a; font-size: 13px; }

html.media-viewer-open,
html.media-viewer-open body { overflow: hidden; }

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  color: #fff;
  background: rgb(0 0 0 / 78%);
  overscroll-behavior: contain;
}
.media-viewer-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.media-viewer-stage:active { cursor: grabbing; }
.media-viewer-image {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: none;
  max-height: none;
  transform-origin: center;
  user-select: none;
  will-change: transform;
}
.media-viewer-close {
  position: absolute;
  z-index: 2;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
}
.media-viewer-status,
.media-viewer-toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
}
.media-viewer-status { gap: 12px; padding: 6px 12px; }
.media-viewer-toolbar { gap: 6px; padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
.media-viewer-toolbar button,
.media-viewer-close {
  min-width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgb(45 45 45 / 88%);
}
.media-viewer-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.loading-mask {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  color: #fff;
  background: rgba(0, 0, 0, .36);
  text-align: center;
}
.spinner { width: 38px; height: 38px; margin: 0 auto; border: 4px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.toast { position: fixed; z-index: 3; bottom: max(22px, env(safe-area-inset-bottom)); left: 50%; padding: 10px 14px; border-radius: 5px; color: #fff; background: rgba(0, 0, 0, .76); transform: translateX(-50%); }
@keyframes spin { to { transform: rotate(1turn); } }

@media (min-width: 900px) {
  #panel[data-screen="chat"] {
    position: absolute;
    top: 18px;
    left: 50%;
    width: 900px;
    height: calc(100% - 36px);
    margin-left: -450px;
    border-radius: 6px;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, .3);
  }
  .support-window {
    width: 890px;
    margin-inline: auto;
  }
  .support-chat-column {
    width: 620px;
    flex: 0 0 620px;
  }
}

@media (max-width: 899px) {
  .support-profile { display: none; }
  .support-chat-column { flex-basis: 100%; }
}

@media (max-width: 760px) {
  #panel[data-screen="chat"] {
    width: 100%;
    min-height: 100%;
    border-radius: 0;
  }
  .support-header { padding-inline: 10px; }
  .support-messages { padding: 6px 9px 14px; }
  .support-composer {
    min-height: calc(58px + env(safe-area-inset-bottom));
    flex-basis: calc(58px + env(safe-area-inset-bottom));
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .image-message { width: min(292px, 100%); }
  .link-card, .quick-replies { width: 100%; }
  .message-content { max-width: calc(100% - 44px); }
  .support-send { padding-inline: 11px; }
  .media-viewer-toolbar {
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
}

@media (max-width: 420px) {
  .audio-message { width: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .media-viewer-image { transition: none !important; }
}
