* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #1f0f37 url("./assets/kod-bg.png") center center / cover no-repeat fixed;
  color: #f5edd8;
  font-family: "Inter", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.kod-page {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(17, 8, 29, 0.72) 0%, rgba(20, 9, 34, 0.84) 100%);
}

.kod-shell {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.kod-chat {
  width: 100%;
  max-width: 680px;
  height: min(780px, calc(100vh - 40px));
  min-height: 560px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(212, 174, 98, 0.16);
  border-radius: 22px;
  overflow: hidden;
  background: rgba(18, 8, 30, 0.72);
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 60px rgba(7, 3, 14, 0.34);
}

.kod-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 12px;
  scroll-behavior: smooth;
}

.kod-row {
  display: flex;
  margin-bottom: 14px;
}

.kod-row.bot {
  justify-content: flex-start;
}

.kod-row.user {
  justify-content: flex-end;
}

.kod-bubble {
  width: min(100%, 540px);
  padding: 11px 13px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 13px;
  word-break: break-word;
}

.kod-row.bot .kod-bubble {
  border-top-left-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.kod-row.user .kod-bubble {
  border-top-right-radius: 8px;
  color: #271336;
  background: linear-gradient(135deg, #d9b66e 0%, #f1d899 100%);
  box-shadow: 0 10px 22px rgba(212, 174, 98, 0.16);
}

.kod-bubble p {
  margin: 0 0 1em;
}

.kod-bubble p:last-child {
  margin-bottom: 0;
}

.kod-bubble strong {
  font-weight: 700;
  color: #fff4d3;
}

.kod-row.user .kod-bubble strong {
  color: #2b143d;
}

.kod-bubble code {
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
}

.kod-row.user .kod-bubble code {
  background: rgba(37, 16, 52, 0.1);
}

.kod-bubble blockquote {
  margin: 1em 0 0;
  padding: 0 0 0 14px;
  border-left: 2px solid rgba(212, 174, 98, 0.58);
  color: rgba(245, 237, 216, 0.88);
}

.kod-row.user .kod-bubble blockquote {
  color: rgba(43, 20, 61, 0.86);
  border-left-color: rgba(43, 20, 61, 0.26);
}

.kod-photo-bubble {
  width: min(100%, 540px);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.kod-photo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  max-height: min(36vh, 300px);
  background: rgba(255, 255, 255, 0.03);
}

.kod-photo-caption {
  padding: 12px 13px;
  font-size: 13px;
  line-height: 1.5;
}

.kod-photo-caption p {
  margin: 0 0 1em;
}

.kod-photo-caption p:last-child {
  margin-bottom: 0;
}

.kod-composer {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(180deg, rgba(21, 9, 34, 0.96) 0%, rgba(18, 8, 30, 0.98) 100%);
}

.kod-input-form.is-hidden,
.kod-actions.is-hidden {
  display: none;
}

.kod-input-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(212, 174, 98, 0.14);
}

.kod-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: none;
  outline: none;
  color: #f5edd8;
  background: transparent;
  font-size: 14px;
}

.kod-input::placeholder {
  color: rgba(245, 237, 216, 0.38);
}

.kod-send {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #d4ae62 0%, #f0d591 100%);
  color: #2d143d;
}

.kod-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.kod-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kod-inline-actions {
  width: min(100%, 540px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kod-inline-actions .kod-action[disabled] {
  opacity: 0.56;
  cursor: default;
  transform: none;
}

.kod-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(212, 174, 98, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #f5edd8;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.kod-action:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(212, 174, 98, 0.28);
  transform: translateY(-1px);
}

.kod-action.primary {
  color: #2c153c;
  background: linear-gradient(135deg, #d4ae62 0%, #f0d591 100%);
  border-color: rgba(255, 244, 211, 0.3);
}

.kod-action.secondary {
  background: rgba(255, 255, 255, 0.04);
}

.kod-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(245, 237, 216, 0.72);
}

.kod-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #d4ae62;
  box-shadow: 0 0 10px rgba(212, 174, 98, 0.55);
  animation: kod-pulse 1.2s infinite;
}

@keyframes kod-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

.kod-toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(16px);
  width: min(calc(100% - 28px), 420px);
  padding: 13px 15px;
  border-radius: 16px;
  background: rgba(22, 10, 34, 0.92);
  border: 1px solid rgba(212, 174, 98, 0.18);
  color: rgba(245, 237, 216, 0.9);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  backdrop-filter: blur(16px);
}

.kod-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 767px) {
  .kod-shell {
    min-height: auto;
    display: block;
    padding: 14px;
  }

  .kod-chat {
    max-width: none;
    height: auto;
    min-height: calc(100vh - 52px);
    border-radius: 22px;
  }

  .kod-messages {
    padding: 18px 12px 12px;
  }

  .kod-bubble,
  .kod-photo-bubble {
    width: 100%;
  }

  .kod-bubble,
  .kod-photo-caption {
    font-size: 14px;
  }

  .kod-photo {
    max-height: none;
  }

  .kod-composer {
    padding: 12px;
  }

  .kod-input-shell {
    padding: 7px;
    border-radius: 18px;
  }

  .kod-input,
  .kod-send {
    height: 44px;
  }

  .kod-send {
    width: 44px;
    border-radius: 14px;
  }

  .kod-action {
    min-height: 48px;
    border-radius: 14px;
  }
}
