.jtal-launcher {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 950;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 98px;
  min-height: 50px;
  padding: 0 20px;
  border: none;
  border-radius: 25px;
  background: linear-gradient(135deg, #7b1fa2, #4a0072);
  box-shadow: 0 8px 24px rgba(74, 0, 114, 0.32);
  color: #fff;
  font: 600 0.92rem/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.jtal-launcher::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #ffeb3b;
  box-shadow: 0 0 0 4px rgba(255, 235, 59, 0.16);
}
.jtal-launcher:hover,
.jtal-launcher:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(74, 0, 114, 0.38);
}
.jtal-launcher.jtal-active {
  background: #fff;
  box-shadow: 0 0 0 2px #7b1fa2, 0 10px 28px rgba(74, 0, 114, 0.32);
  color: #4a0072;
}
.jtal-launcher.jtal-active::before {
  background: #7b1fa2;
  box-shadow: 0 0 0 4px rgba(123, 31, 162, 0.12);
}
.jtal-panel {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 58px);
  z-index: 1200;
  display: none;
  grid-template-rows: auto auto minmax(180px, 1fr) auto auto;
  width: min(430px, calc(100vw - 32px));
  max-height: min(700px, calc(100dvh - 92px));
  overflow: hidden;
  border: 1px solid var(--border, #f3e5f5);
  border-radius: 10px;
  background: var(--bg, #f5f9ff);
  box-shadow: 0 22px 58px rgba(74, 0, 114, 0.24);
  color: var(--text, #1a237e);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  text-align: left;
}
.jtal-panel.jtal-open { display: grid; }
.jtal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, #7b1fa2, #4a0072);
}
.jtal-title {
  margin: 0;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.3;
}
.jtal-description {
  margin: 4px 0 0;
  color: #f3e5f5;
  font-size: 0.76rem;
  line-height: 1.4;
}
.jtal-icon-button {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.jtal-icon-button:hover,
.jtal-icon-button:focus-visible { border-color: #ffeb3b; }
.jtal-quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 12px;
  border-bottom: 1px solid var(--border, #f3e5f5);
  background: #fff;
}
.jtal-quick-button,
.jtal-action,
.jtal-special-action,
.jtal-submit,
.jtal-clear {
  min-height: 38px;
  border: 1px solid rgba(123, 31, 162, 0.18);
  border-radius: 8px;
  font: 600 0.78rem/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  cursor: pointer;
}
.jtal-quick-button {
  min-width: 0;
  min-height: 42px;
  padding: 7px 9px;
  background: #f3e5f5;
  color: #4a0072;
  text-align: left;
}
.jtal-quick-button:nth-child(1),
.jtal-quick-button:nth-child(2) {
  border-color: rgba(255, 179, 0, 0.28);
  background: #fff8e1;
  color: #6d4700;
}
.jtal-quick-button:hover,
.jtal-quick-button:focus-visible { border-color: rgba(123, 31, 162, 0.42); }
.jtal-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg, #f5f9ff);
}
.jtal-message {
  max-width: 92%;
  padding: 11px 12px;
  border: 1px solid var(--border, #f3e5f5);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.04);
  color: #37474f;
  font-size: 0.86rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.jtal-message-user {
  justify-self: end;
  border-color: rgba(123, 31, 162, 0.16);
  background: #f3e5f5;
  color: #4a0072;
}
.jtal-message-title {
  display: block;
  margin-bottom: 4px;
  color: #4a0072;
  font-weight: 700;
}
.jtal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}
.jtal-action,
.jtal-special-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  background: #f3e5f5;
  color: #4a0072;
  text-decoration: none;
}
.jtal-special-action {
  border: none;
  background: linear-gradient(135deg, #ffb300, #ff9800);
  color: #1a237e;
}
.jtal-note {
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid var(--border, #f3e5f5);
  background: #fff;
  color: #7e57c2;
  font-size: 0.69rem;
  line-height: 1.4;
}
.jtal-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border, #f3e5f5);
  background: #fff;
}
.jtal-input {
  min-width: 0;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid rgba(123, 31, 162, 0.18);
  border-radius: 8px;
  outline: none;
  background: #fff;
  color: #263238;
  font: inherit;
  pointer-events: auto;
  touch-action: auto;
}
.jtal-input:focus {
  border-color: rgba(123, 31, 162, 0.5);
  box-shadow: 0 0 0 3px rgba(123, 31, 162, 0.12);
}
.jtal-submit {
  padding: 0 14px;
  border: none;
  background: linear-gradient(135deg, #7b1fa2, #4a0072);
  color: #fff;
}
.jtal-submit:disabled,
.jtal-input:disabled { cursor: wait; opacity: 0.65; }
.jtal-clear {
  grid-column: 1 / -1;
  min-height: 30px;
  border-color: transparent;
  background: transparent;
  color: #7e57c2;
}
@media (max-width: 560px) {
  .jtal-launcher {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    min-width: 86px;
  }
  .jtal-launcher.jtal-active { display: none; }
  .jtal-panel {
    top: calc(var(--jtal-viewport-top, 0px) + max(8px, env(safe-area-inset-top)));
    right: 8px;
    bottom: auto;
    left: 8px;
    width: auto;
    height: calc(min(var(--jtal-viewport-height, 100dvh), 100dvh) - 16px);
    max-height: calc(min(var(--jtal-viewport-height, 100dvh), 100dvh) - 16px);
    grid-template-rows: auto minmax(0, auto) minmax(70px, 1fr) auto auto;
  }
  .jtal-quick { max-height: 150px; overflow-y: auto; overscroll-behavior: contain; }
  .jtal-quick-button { min-height: 46px; font-size: 0.74rem; }
  .jtal-message { max-width: 96%; }
  .jtal-form { position: relative; z-index: 2; }
  .jtal-input { font-size: 16px; }
}
@media (max-width: 360px) {
  .jtal-quick { grid-template-columns: 1fr; }
}
@media (max-width: 900px) and (max-height: 560px) {
  .jtal-description,
  .jtal-note { display: none; }
  .jtal-header { padding: 10px 14px; }
  .jtal-quick {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
    max-height: 88px;
    overflow: auto;
    padding: 8px;
  }
  .jtal-quick-button { min-height: 34px; }
  .jtal-messages { padding: 9px 12px; }
  .jtal-form { padding-top: 7px; }
}
