:root {
  --terminal-cyan: #86ffff;
  --terminal-green: #63ffb4;
  --terminal-ink: rgba(2, 10, 14, 0.82);
  --terminal-line: rgba(134, 255, 255, 0.35);
}

.terminal-chat {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 20;
  color: #eaffff;
  font-family: "Space Mono", monospace;
  font-size: 12px;
}

.terminal-launcher {
  min-width: 188px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--terminal-line);
  border-radius: 2px;
  background: rgba(2, 12, 16, 0.64);
  color: var(--terminal-cyan);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.18), inset 0 0 18px rgba(0, 255, 255, 0.04);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font: 700 11px/1 "Space Mono", monospace;
  letter-spacing: 0.12em;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.terminal-launcher:hover,
.terminal-launcher:focus-visible {
  border-color: var(--terminal-cyan);
  background: rgba(2, 18, 24, 0.82);
  outline: none;
  transform: translateY(-2px);
}

.terminal-status {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--terminal-green);
  box-shadow: 0 0 8px var(--terminal-green);
  animation: terminal-pulse 1.4s steps(2, end) infinite;
}

.terminal-symbol {
  margin-left: auto;
  color: #fff;
  animation: terminal-cursor 0.9s steps(1, end) infinite;
}

.terminal-window {
  width: min(410px, calc(100vw - 3rem));
  height: min(570px, calc(100vh - 3rem));
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  border: 1px solid var(--terminal-line);
  border-radius: 3px;
  background:
    linear-gradient(rgba(255,255,255,0.015) 50%, rgba(0,0,0,0.025) 50%) 0 0 / 100% 4px,
    var(--terminal-ink);
  box-shadow: 0 0 36px rgba(0, 255, 255, 0.2), 0 18px 70px rgba(0,0,0,0.48);
  backdrop-filter: blur(16px) saturate(115%);
  -webkit-backdrop-filter: blur(16px) saturate(115%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
}

.terminal-chat.is-open .terminal-window {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

.terminal-chat.is-open .terminal-launcher { display: none; }

.terminal-header {
  min-height: 42px;
  padding: 0 0.85rem;
  border-bottom: 1px solid rgba(134, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--terminal-cyan);
  font-size: 10px;
  letter-spacing: 0.09em;
}

.terminal-header > span { display: flex; align-items: center; gap: 0.55rem; }

.terminal-close {
  border: 0;
  padding: 0.4rem;
  background: transparent;
  color: rgba(234, 255, 255, 0.7);
  cursor: pointer;
  font: 700 14px "Space Mono", monospace;
}

.terminal-close:hover,
.terminal-close:focus-visible { color: #fff; outline: 1px solid var(--terminal-line); }

.terminal-output {
  overflow-y: auto;
  padding: 1rem;
  scrollbar-color: rgba(134,255,255,.4) transparent;
}

.terminal-line {
  margin: 0 0 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

.terminal-system { color: rgba(174, 218, 220, 0.72); }
.terminal-user { color: #fff; }
.terminal-user::before { content: "> "; color: var(--terminal-green); }
.terminal-assistant { color: var(--terminal-cyan); }
.terminal-assistant::before { content: "oco:// "; color: rgba(99, 255, 180, 0.85); }
.terminal-error { color: #ff9f9f; }
.terminal-typing::after { content: "▋"; margin-left: 0.2rem; animation: terminal-cursor .8s steps(1,end) infinite; }

.terminal-form {
  min-height: 54px;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid rgba(134, 255, 255, 0.22);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.terminal-prompt { color: var(--terminal-green); white-space: nowrap; }

.terminal-form input {
  min-width: 0;
  flex: 1;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  caret-color: var(--terminal-green);
  font: 12px/1.4 "Space Mono", monospace;
}

.terminal-form input::placeholder { color: rgba(224,255,255,.34); }
.terminal-form input:disabled { opacity: .55; }

.terminal-form button {
  border: 0;
  background: transparent;
  color: var(--terminal-cyan);
  cursor: pointer;
  font: 700 18px "Space Mono", monospace;
}

.terminal-notice {
  margin: 0;
  padding: 0.45rem 0.85rem;
  border-top: 1px solid rgba(134,255,255,.09);
  color: rgba(174,218,220,.45);
  font-size: 8px;
  letter-spacing: .12em;
  text-align: right;
}

.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;
}

@keyframes terminal-pulse { 50% { opacity: .3; } }
@keyframes terminal-cursor { 50% { opacity: 0; } }

@media (max-width: 800px) {
  .terminal-chat { right: 0.75rem; bottom: 0.75rem; }
  .terminal-window {
    width: calc(100vw - 1.5rem);
    height: min(68vh, 560px);
  }
  .terminal-launcher { min-width: 0; }
  .terminal-launcher-label { display: none; }
  .terminal-symbol { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .terminal-status, .terminal-symbol, .terminal-typing::after { animation: none; }
  .terminal-window, .terminal-launcher { transition: none; }
}
