:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #14213d;
  --muted: #6b7280;
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --border: #dbe4f0;
  --user-bubble: #1d4ed8;
  --bot-bubble: #eef3ff;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #eef4ff 100%);
  color: var(--text);
}

.widget-shell {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
}

.chat-toggle {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  min-width: 68px;
  height: 68px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
}

.chat-panel {
  width: min(380px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 100px));
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.hidden {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.chat-header h1 {
  margin: 0;
  font-size: 18px;
}

.chat-header p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.ghost-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.message-list {
  padding: 16px;
  overflow-y: auto;
  background: var(--bg);
}

.message {
  max-width: 86%;
  padding: 11px 13px;
  margin-bottom: 12px;
  border-radius: 18px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

.message--user {
  margin-left: auto;
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.message--bot,
.message--system {
  margin-right: auto;
  background: var(--bot-bubble);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.message--typing {
  color: var(--muted);
  font-style: italic;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: #fff;
}

.chat-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.chat-form button {
  border: 0;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

.chat-form button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .widget-shell {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .chat-panel {
    width: 100%;
    height: min(72vh, 560px);
  }

  .chat-toggle {
    margin-left: auto;
    display: block;
  }
}
