:root {
  --bg-dark: #0a0a0a;
  --bg-terminal: #0d1117;
  --green: #00ff41;
  --green-dim: #33cc55;
  --green-glow: rgba(0, 255, 65, 0.2);
  --white: #f0f0f0;
  --red: #ff3333;
  --border: #1a3a1a;
  --font: 'Courier New', Courier, 'Liberation Mono', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  font-family: var(--font);
  color: var(--green);
  font-size: 14px;
}

.hidden { display: none !important; }

/* Terminal container */
.terminal {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg-terminal);
  position: relative;
}

/* Header bar */
.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 6px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-dots {
  display: flex;
  gap: 5px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }

.header-title {
  color: var(--green-dim);
  font-size: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  flex-wrap: wrap;
}

.connection-status {
  color: var(--green-dim);
}
.connection-status.offline {
  color: var(--red);
}

.sound-toggle {
  color: var(--green-dim);
  cursor: pointer;
  user-select: none;
}
.sound-toggle:hover {
  color: var(--green);
}

.header-link {
  color: var(--green-dim);
  text-decoration: none;
}
.header-link:hover {
  color: var(--green);
  text-decoration: underline;
}

/* Chat area */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scroll-behavior: smooth;
}

/* Scanline overlay */
.chat-area::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 10;
}

/* Messages */
.message {
  margin-bottom: 12px;
  line-height: 1.6;
  word-wrap: break-word;
  position: relative;
}

.message-line {
  position: relative;
  padding-right: 90px;
}

.message-content {
  min-width: 0;
}

.message-timestamp {
  position: absolute;
  top: 0;
  right: 0;
  color: var(--green-dim);
  font-size: 11px;
  white-space: nowrap;
  opacity: 0.6;
}

.message.bot .message-content {
  color: var(--green);
  text-shadow: 0 0 5px var(--green-glow);
}

.message.user .message-content {
  color: var(--white);
}

.message.system .message-content {
  color: var(--green-dim);
}

.message.error .message-content {
  color: var(--red);
}

/* Boot sequence */
.boot-line {
  color: var(--green-dim);
  margin-bottom: 2px;
  line-height: 1.4;
}

.topic-link {
  color: var(--green);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}
.topic-link:hover {
  text-shadow: 0 0 8px var(--green-glow);
}

/* Copy button */
.copy-btn {
  background: none;
  border: none;
  color: var(--green-dim);
  font-family: var(--font);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  margin-left: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.message:hover .copy-btn {
  opacity: 1;
}

/* Feedback */
.feedback {
  margin-top: 4px;
  font-size: 12px;
}

.feedback-btn {
  background: none;
  border: none;
  color: var(--green-dim);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
}
.feedback-btn:hover {
  color: var(--green);
}

.feedback-result {
  color: var(--green-dim);
  font-size: 12px;
}

/* Typing indicator */
.typing-indicator {
  color: var(--green-dim);
  margin-bottom: 12px;
}

.blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Image preview */
.image-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-dark);
}

.preview-label {
  color: var(--green-dim);
  font-size: 11px;
}

.image-preview img {
  max-height: 50px;
  max-width: 80px;
  border: 1px solid var(--border);
}

.preview-remove {
  background: none;
  border: none;
  color: var(--red);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
}

.message-image {
  max-width: 200px;
  border: 1px solid var(--border);
  margin-bottom: 4px;
  display: block;
}

/* Message counter */
.message-counter {
  padding: 4px 12px;
  color: var(--green-dim);
  font-size: 11px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Input area */
.input-area {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-dark);
  flex-shrink: 0;
  gap: 8px;
}

.input-prompt {
  color: var(--green);
  font-size: 14px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  font-family: var(--font);
  font-size: 14px;
  caret-color: var(--green);
  min-width: 0;
}

.chat-input::placeholder {
  color: var(--green-dim);
  opacity: 0.5;
}

.chat-input:disabled {
  opacity: 0.4;
}

.attach-btn,
.send-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--green-dim);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.send-btn {
  color: var(--green);
  border-color: var(--green-dim);
}

.send-btn:hover:not(:disabled) {
  background: var(--green-glow);
  border-color: var(--green);
}

.send-btn:disabled,
.attach-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Rate limit card */
.rate-limit-card {
  padding: 16px 12px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  color: var(--green-dim);
  font-size: 13px;
  line-height: 1.6;
}

.rate-limit-card a {
  color: var(--green);
  text-decoration: underline;
}

/* Scroll to bottom button */
.scroll-btn {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 17, 23, 0.9);
  color: var(--green);
  font-family: var(--font);
  font-size: 12px;
  border: 1px solid var(--green-dim);
  padding: 6px 14px;
  cursor: pointer;
  z-index: 5;
}

.scroll-btn:hover {
  background: var(--green-glow);
  border-color: var(--green);
}

/* Bold text in bot messages */
.text-bold {
  color: var(--green);
  font-weight: bold;
  text-shadow: 0 0 8px var(--green-glow);
}

/* Safe links in bot messages */
.safe-link {
  color: var(--green);
  text-decoration: underline;
}

/* Mobile: always show copy button */
@media (max-width: 480px) {
  .copy-btn {
    opacity: 1;
  }

  .header-right {
    font-size: 10px;
    gap: 8px;
  }

  .terminal {
    border: none;
  }

  body {
    font-size: 13px;
  }
}

@media (min-width: 481px) {
  .terminal {
    margin-top: 0;
  }
}
