.chat-view {
  --chat-terminal-width: min(1536px, calc(100vw - 48px));
}

.chat-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  height: calc(100vh - 112px);
  font-family: Consolas, Monaco, "Courier New", monospace;
}

.terminal-hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 50px;
  padding: 8px 14px;
  border: 1px solid rgba(0, 179, 134, 0.72);
  border-radius: 8px;
  background: #05080b;
  color: #c9d1d9;
  overflow: visible;
  box-shadow: 0 0 0 1px rgba(0, 179, 134, 0.08), 0 10px 28px rgba(0, 0, 0, 0.22);
  width: var(--chat-terminal-width);
  max-width: var(--chat-terminal-width);
  margin: 0 auto;
}

.terminal-title {
  position: static;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  color: #7ee787;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.terminal-title small {
  color: #8b949e;
  font-weight: 800;
}

.terminal-pane {
  min-height: 0;
  padding: 0;
}

.terminal-pane strong {
  display: block;
  color: #7ee787;
  font-size: 14px;
  margin-bottom: 8px;
}

.terminal-pane p {
  margin: 0 0 18px;
  color: #8b949e;
  line-height: 1.45;
}

.terminal-welcome {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  text-align: left;
  flex-wrap: wrap;
}

.terminal-token {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid rgba(0, 179, 134, 0.26);
  border-radius: 6px;
  background: rgba(0, 179, 134, 0.06);
  color: #a7b0ba;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.terminal-token:nth-child(1),
.terminal-token:nth-child(5) {
  color: #7ee787;
}

.terminal-token:nth-child(4) {
  color: #00d4ff;
}

.mobile-chat-hero {
  display: none;
}

.chat-feed {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid #27313c;
  border-bottom: 1px solid #27313c;
  padding: 14px 4px 14px 0;
  width: var(--chat-terminal-width);
  max-width: var(--chat-terminal-width);
  margin: 0 auto;
  scrollbar-color: #27313c #05080b;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.ai {
  justify-content: flex-start;
}

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

.message-row.system {
  justify-content: flex-start;
}

.bubble {
  display: inline-block;
  width: fit-content;
  max-width: min(980px, 78%);
  border-radius: 16px;
  padding: 10px 12px;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.bubble.ai {
  justify-self: start;
  background: #eef2f7;
}

.bubble.user {
  background: #2563eb;
  color: #fff;
  max-width: min(520px, 52%);
}

.bubble.system {
  max-width: 100%;
  border: 1px dashed rgba(0, 179, 134, 0.42);
  background: rgba(0, 179, 134, 0.06);
  color: #8b949e;
  font-size: 12px;
}

.bubble-head {
  font-size: 11px;
  color: #7ee787;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.bubble.user .bubble-head {
  color: #7ee787;
}

.bubble.system .bubble-head {
  color: #7ee787;
}

.bubble-body {
  line-height: 1.45;
  white-space: pre-wrap;
}

.code-block {
  position: relative;
  display: grid;
  gap: 10px;
  margin: 10px 0;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 38px 14px 14px;
  background: #05080b;
  color: #d7fbe8;
  white-space: pre-wrap;
  overflow-x: auto;
  overflow-wrap: anywhere;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.code-block-head {
  position: absolute;
  inset: 8px 8px auto 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.code-block span {
  color: #00d4ff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.code-copy {
  width: 32px;
  height: 32px;
  min-height: 0;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 0;
  display: grid;
  place-items: center;
  background: #111b25;
  color: #e6edf3;
  cursor: pointer;
}

.code-copy:hover,
.code-copy.copied {
  border-color: #8b949e;
  background: #1a242f;
}

.code-copy[data-state="copied"]::after {
  content: "Copied";
  position: absolute;
  right: 0;
  top: 36px;
  border: 1px solid #27313c;
  border-radius: 8px;
  padding: 4px 8px;
  background: #111b25;
  color: #7ee787;
  font-size: 11px;
}

.copy-icon {
  position: relative;
  width: 15px;
  height: 15px;
  display: block;
}

.copy-icon::before,
.copy-icon::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 11px;
  border: 1.7px solid currentColor;
  border-radius: 3px;
}

.copy-icon::before {
  left: 1px;
  top: 3px;
  opacity: 0.7;
}

.copy-icon::after {
  left: 5px;
  top: 0;
}

.code-block code {
  font-family: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-meta {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.35;
  color: #64748b;
}

.bubble-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(100, 116, 139, 0.16);
}

.bubble-sources-title {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.bubble-sources ul {
  margin: 0;
  padding-left: 16px;
}

.bubble-sources li {
  margin: 2px 0;
  font-size: 11px;
  line-height: 1.35;
}

.bubble-sources a {
  color: #1d4ed8;
  text-decoration: none;
}

.composer {
  position: relative;
  background: #05080b;
  border: 1px solid #27313c;
  border-radius: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 10px 10px 14px;
  width: var(--chat-terminal-width);
  max-width: var(--chat-terminal-width);
  margin: 0 auto;
}

.slash-palette {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 10px);
  display: none;
  overflow: hidden;
  border: 1px solid #27313c;
  border-radius: 8px;
  background: #0b1117;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(0, 179, 134, 0.08);
  z-index: 15;
}

.slash-palette.open {
  display: block;
}

.slash-palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #27313c;
  color: #8b949e;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.slash-palette-head kbd {
  border: 1px solid #27313c;
  border-radius: 5px;
  padding: 1px 5px;
  background: #05080b;
  color: #7ee787;
  font-family: inherit;
  font-size: 10px;
}

.slash-palette-list {
  max-height: 320px;
  overflow: auto;
  padding: 6px;
}

.slash-item {
  width: 100%;
  display: grid;
  grid-template-columns: 150px 1fr 86px;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: #c9d1d9;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.slash-item:hover,
.slash-item.active {
  background: #111b25;
}

.slash-item.locked {
  opacity: 0.56;
}

.slash-command {
  color: #7ee787;
  font-weight: 800;
}

.slash-command small {
  display: block;
  margin-top: 2px;
  color: #8b949e;
  font-size: 10px;
  font-weight: 700;
}

.slash-desc {
  color: #c9d1d9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-group {
  justify-self: end;
  color: #00d4ff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.slash-empty {
  padding: 18px;
  color: #8b949e;
  text-align: center;
}

.slash-empty code {
  color: #7ee787;
}

.composer::before {
  content: ">";
  color: #7ee787;
  font-weight: 900;
}

.composer textarea {
  border: none;
  resize: none;
  max-height: 130px;
  min-height: 40px;
  padding: 9px 10px;
  font-family: inherit;
}

.composer textarea:focus {
  outline: none;
}

.btn.send {
  align-self: end;
  min-width: 82px;
  font-family: inherit;
}

.legacy-chat-composer {
  display: none !important;
}

@media (max-width: 900px) {
  .chat-view {
    --chat-terminal-width: calc(100vw - 28px);
  }

  body {
    background: #f7f9fc;
  }

  .chat-view {
    height: calc(100vh - 58px);
    grid-template-rows: auto 1fr auto;
    gap: 12px;
    padding: 46px 14px 24px;
    overflow: hidden;
  }

  .terminal-hero {
    align-items: flex-start;
    min-height: 68px;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .terminal-pane {
    min-height: 0;
    padding: 0;
    width: 100%;
  }

  .terminal-welcome {
    justify-content: flex-start;
    gap: 6px;
  }

  .terminal-token {
    min-height: 24px;
    padding: 4px 7px;
    font-size: 11px;
  }

  .mobile-chat-hero {
    display: none;
  }

  .mobile-chat-avatar {
    width: 58px;
    height: 58px;
    border-radius: 999px;
    background:
      radial-gradient(circle at 50% 42%, rgba(56, 189, 248, 0.95) 0 5%, transparent 6%),
      radial-gradient(circle at 50% 50%, rgba(14, 165, 233, 0.22), transparent 52%),
      linear-gradient(135deg, #0f172a, #052e36);
    box-shadow: 0 0 0 3px rgba(47, 110, 234, 0.08), 0 8px 24px rgba(15, 23, 42, 0.18);
  }

  .mobile-chat-hero h3 {
    margin: 8px 0 0;
    color: #2f343b;
    font-size: 21px;
    line-height: 1.2;
  }

  .mobile-chat-hero p {
    max-width: 260px;
    margin: 0;
    color: #89919d;
    font-size: 14px;
    line-height: 1.45;
    font-weight: 700;
  }

  .chat-feed {
    gap: 28px;
    padding: 0 0 6px;
    width: var(--chat-terminal-width);
    max-width: var(--chat-terminal-width);
  }

  .bubble {
    max-width: 82%;
    border-radius: 24px;
    padding: 18px 20px;
    font-size: 15px;
    line-height: 1.45;
    box-shadow: none;
  }

  .bubble.ai {
    background: #e9edf2;
    color: #4b5563;
    border-bottom-left-radius: 8px;
  }

  .bubble.user {
    max-width: 80%;
    background: #075bd8;
    border-bottom-right-radius: 8px;
  }

  .bubble-head,
  .bubble-meta,
  .bubble-sources {
    display: none;
  }

  .message-row {
    position: relative;
  }

  .message-row[data-time]::after {
    content: attr(data-time);
    position: absolute;
    bottom: -18px;
    color: #9ca3af;
    font-size: 10px;
    font-weight: 700;
  }

  .message-row.ai::after {
    left: 8px;
  }

  .message-row.user::after {
    right: 8px;
  }

  .composer {
    grid-template-columns: auto 1fr 46px;
    gap: 6px;
    align-items: center;
    min-height: 58px;
    border: 1px solid #27313c;
    border-radius: 8px;
    padding: 7px 8px 7px 14px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    width: var(--chat-terminal-width);
    max-width: var(--chat-terminal-width);
  }

  .slash-item {
    grid-template-columns: 110px 1fr;
  }

  .slash-group {
    display: none;
  }

  .composer::before {
    width: auto;
    height: auto;
    color: #7ee787;
    font-size: 18px;
    font-weight: 900;
  }

  .composer textarea {
    min-height: 36px;
    padding: 9px 2px;
    background: transparent;
    color: #475569;
  }

  .composer textarea::placeholder {
    color: #b5bdc9;
    font-weight: 700;
  }

  .btn.send {
    grid-column: 3;
    min-width: 0;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    padding: 0;
    align-self: center;
    font-size: 0;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.24);
  }

  .btn.send::before {
    content: ">";
    font-size: 26px;
    line-height: 1;
    font-weight: 700;
  }
}

/* KEVIN AI chat dark theme overrides */
.chat-feed {
  scrollbar-color: #27313c #080c10;
}

.bubble {
  border-radius: 8px;
  border: 1px solid transparent;
}

.bubble.ai {
  border-color: #27313c;
  background: #111b25;
  color: #c9d1d9;
}

.bubble.user {
  border-color: rgba(0, 179, 134, 0.42);
  background: #2a2d31;
  color: #f0f6fc;
}

.bubble.system {
  border-radius: 8px;
  border-color: rgba(0, 179, 134, 0.42);
  background: rgba(0, 179, 134, 0.06);
  color: #8b949e;
}

.bubble-head {
  color: #7ee787;
  letter-spacing: 0;
}

.bubble.user .bubble-head {
  color: #7ee787;
}

.bubble-meta,
.bubble-sources-title {
  color: #8b949e;
}

.bubble-sources {
  border-top-color: #27313c;
}

.bubble-sources a {
  color: #00d4ff;
}

.message-row.thinking {
  opacity: 0.98;
}

.bubble.thinking {
  border-color: rgba(126, 231, 135, 0.42);
  background:
    linear-gradient(90deg, rgba(126, 231, 135, 0.06), rgba(0, 212, 255, 0.04)),
    #0b1117;
  color: #c9d1d9;
}

.bubble.thinking .bubble-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.thinking-line {
  color: #f0f6fc;
  font-weight: 800;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #7ee787;
  box-shadow: 0 0 10px rgba(126, 231, 135, 0.55);
  animation: kevinThinkingDot 1.05s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.thinking-cursor {
  width: 9px;
  height: 17px;
  display: inline-block;
  background: #7ee787;
  box-shadow: 0 0 12px rgba(126, 231, 135, 0.65);
  animation: kevinThinkingCursor 0.9s steps(1, end) infinite;
}

.thinking-subline {
  flex-basis: 100%;
  color: #8b949e;
  font-size: 12px;
  line-height: 1.45;
}

@keyframes kevinThinkingDot {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes kevinThinkingCursor {
  0%,
  48% {
    opacity: 1;
  }

  49%,
  100% {
    opacity: 0.2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .thinking-dots span,
  .thinking-cursor {
    animation: none;
  }

  .thinking-cursor {
    opacity: 1;
  }
}

.user-command-label {
  margin-bottom: 8px;
  color: #7ee787;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.composer {
  border-color: #27313c;
  border-radius: 8px;
  background: #05080b;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
}

.composer textarea {
  color: #e6edf3;
  background: transparent;
}

.composer textarea::placeholder {
  color: #6e7681;
}

.mobile-chat-avatar {
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(126, 231, 135, 0.95) 12%, transparent 12% 20%, rgba(0, 212, 255, 0.95) 20% 32%, transparent 32%),
    linear-gradient(135deg, #0c1a17, #0b1f27);
  box-shadow: 0 0 0 1px #27313c, 0 12px 28px rgba(0, 0, 0, 0.32);
}

.mobile-chat-hero h3 {
  color: #f0f6fc;
}

.mobile-chat-hero p {
  color: #8b949e;
}

@media (max-width: 900px) {
  .chat-view {
    background: #080c10;
  }

  .bubble {
    border-radius: 8px;
  }

  .bubble.ai {
    background: #111b25;
    color: #c9d1d9;
    border-bottom-left-radius: 8px;
  }

  .bubble.user {
    background: #2a2d31;
    color: #f0f6fc;
    border-bottom-right-radius: 8px;
  }

  .composer {
    border: 1px solid #27313c;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  }

  .composer::before {
    color: #7ee787;
    opacity: 0.9;
  }

  .btn.send {
    border-radius: 8px;
  }
}

@media (min-width: 901px) {
  .chat-feed {
    gap: 18px;
  }

  .message-row.ai {
    justify-content: flex-start;
  }

  .message-row.ai .bubble {
    width: min(100%, calc(100vw - 130px));
    max-width: min(100%, calc(100vw - 130px));
    border: 1px solid #27313c;
    border-radius: 8px;
    padding: 16px 18px;
    background: #111b25;
    color: #d9e2ec;
  }

  .message-row.user .bubble {
    max-width: min(900px, 86%);
    border: 0;
    border-radius: 8px;
    padding: 14px 18px;
    background: #2a2d31;
    color: #f0f6fc;
  }

  .message-row.system .bubble {
    width: min(100%, 860px);
    max-width: min(100%, 860px);
  }
}
