:root {
  --bg: #071522;
  --card: #0f2336;
  --card-2: #122a41;
  --text: #ecf4fd;
  --muted: #a6bfd8;
  --line: #2c4f70;
  --accent: #37d66b;
  --accent-2: #17b4ff;
  --warn: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(110% 65% at 6% 0%, rgba(23, 180, 255, 0.22) 0%, rgba(23, 180, 255, 0) 56%),
    radial-gradient(100% 80% at 100% 100%, rgba(55, 214, 107, 0.16) 0%, rgba(55, 214, 107, 0) 58%),
    linear-gradient(170deg, #04101b 0%, #091f33 100%);
  color: var(--text);
  font-family: "Manrope", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

.kim-widget {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-height: 100vh;
  position: relative;
  isolation: isolate;
}

.kim-widget::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.15;
  pointer-events: none;
}

.kim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 15px 12px;
  border-bottom: 1px solid rgba(44, 79, 112, 0.72);
  background: rgba(6, 20, 33, 0.78);
  backdrop-filter: blur(10px);
}

.kim-title-wrap h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  font-weight: 800;
}

.kim-title-wrap p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.ghost-btn {
  border: 1px solid rgba(58, 93, 123, 0.95);
  background: linear-gradient(180deg, rgba(18, 42, 65, 0.92), rgba(14, 33, 51, 0.92));
  color: var(--text);
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 120ms ease, border-color 150ms ease, background 150ms ease;
}

.ghost-btn:hover {
  transform: translateY(-1px);
  border-color: #67a4d2;
  background: linear-gradient(180deg, rgba(23, 53, 82, 0.95), rgba(16, 38, 58, 0.95));
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}

.bubble {
  max-width: 88%;
  padding: 10px 12px 9px;
  border-radius: 13px;
  border: 1px solid transparent;
  line-height: 1.42;
  font-size: 13px;
  font-weight: 500;
  white-space: pre-wrap;
  box-shadow: 0 8px 24px rgba(2, 10, 17, 0.26);
  animation: bubble-in 180ms ease;
}

.bubble.user {
  align-self: flex-end;
  background: linear-gradient(155deg, #114266 0%, #0f3552 100%);
  border-color: #2c6c99;
}

.bubble.kim {
  align-self: flex-start;
  background: linear-gradient(150deg, rgba(19, 41, 61, 0.95), rgba(14, 32, 49, 0.95));
  border-color: rgba(58, 93, 123, 0.88);
}

.bubble.system {
  align-self: center;
  background: rgba(255, 209, 102, 0.12);
  border-color: rgba(255, 209, 102, 0.34);
  color: #ffecc1;
}

.timestamp {
  display: block;
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.86;
}

.status-bar {
  margin: 0 14px 10px;
  border: 1px solid #3e6281;
  background: linear-gradient(120deg, rgba(23, 180, 255, 0.12), rgba(55, 214, 107, 0.1));
  border-radius: 11px;
  color: #cdefff;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
}

.chat-form {
  border-top: 1px solid rgba(44, 79, 112, 0.8);
  padding: 10px 14px 14px;
  background: rgba(6, 20, 33, 0.88);
  backdrop-filter: blur(8px);
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 56px;
  max-height: 180px;
  border-radius: 11px;
  border: 1px solid rgba(57, 90, 119, 0.86);
  background: linear-gradient(160deg, rgba(19, 43, 66, 0.95), rgba(15, 33, 51, 0.95));
  color: var(--text);
  padding: 10px 11px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.35;
}

.chat-form textarea:focus {
  outline: 1px solid var(--accent-2);
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(23, 180, 255, 0.18);
}

.form-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

#send-btn {
  border: 0;
  border-radius: 11px;
  padding: 9px 14px;
  background: linear-gradient(135deg, #1eb95a 0%, #39d979 100%);
  color: #05210f;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(40, 208, 114, 0.35);
  transition: transform 120ms ease, box-shadow 140ms ease, filter 140ms ease;
}

#send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.02);
  box-shadow: 0 11px 26px rgba(40, 208, 114, 0.43);
}

#send-btn:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

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

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
