/* retoor <retoor@molodetz.nl> */

devii-terminal {
  --devii-bg: #000000;
  --devii-fg: #d0d0d0;
  --devii-dim: #6a737d;
  --devii-user: #58a6ff;
  --devii-agent: #e6edf3;
  --devii-error: #ff6b6b;
  --devii-task: #d2a8ff;
  --devii-accent: #3fb950;
  --devii-bar-bg: #0b0b0b;
  --devii-border: #1c1f24;
  --devii-code-bg: #11151a;
  --devii-code-fg: #7ee787;
  --devii-hover-bg: #1b1f25;
  --devii-toolbar-bg: #060606;
  --devii-tok-kw: #ff7b72;
  --devii-tok-str: #a5d6ff;
  --devii-tok-num: #f2cc60;
  --devii-tok-lit: #d2a8ff;
  --devii-link: #58a6ff;
  --devii-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  --devii-radius: 10px;
  --devii-font: "SFMono-Regular", "JetBrains Mono", "Fira Code", Consolas, "Courier New", monospace;
  --devii-font-size: 14px;
  --devii-z: var(--z-chrome-devii);

  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--devii-z);
  font-family: var(--devii-font);
  font-size: var(--devii-font-size);
}

devii-terminal .devii-launcher,
devii-terminal .devii-window,
.devii-hl-box,
.devii-hl-callout,
.devii-toast {
  will-change: transform;
}

/* Launcher FAB (shown only when closed) */
devii-terminal .devii-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  pointer-events: auto;
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--devii-bar-bg);
  color: var(--devii-accent);
  border: 1px solid var(--devii-border);
  border-radius: 24px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--devii-shadow);
}

devii-terminal .devii-launcher:hover {
  border-color: var(--devii-accent);
}

devii-terminal .devii-launcher-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--devii-accent);
  box-shadow: 0 0 8px var(--devii-accent);
}

/* Window */
devii-terminal .devii-window {
  position: fixed;
  pointer-events: auto;
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-width: 300px;
  min-height: 220px;
  max-width: 100vw;
  max-height: 100vh;
  background: var(--devii-bg);
  color: var(--devii-fg);
  border: 1px solid var(--devii-border);
  border-radius: var(--devii-radius);
  box-shadow: var(--devii-shadow);
  line-height: 1.5;
  animation: devii-pop 0.16s ease;
  transition: top 0.18s ease, left 0.18s ease, width 0.18s ease, height 0.18s ease;
}

@keyframes devii-pop {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

devii-terminal.devii-dragging .devii-window {
  transition: none;
  user-select: none;
}

/* State visibility */
devii-terminal.devii-state-closed .devii-launcher {
  display: none;
}
devii-terminal.devii-state-normal .devii-window,
devii-terminal.devii-state-maximized .devii-window,
devii-terminal.devii-state-fullscreen .devii-window {
  display: flex;
}

devii-terminal.devii-state-normal .devii-window {
  resize: both;
}
devii-terminal.devii-state-normal .devii-titlebar {
  cursor: move;
}

devii-terminal.devii-state-maximized .devii-window {
  top: 12px;
  left: 12px;
  right: 12px;
  bottom: 12px;
  width: auto;
  height: auto;
  resize: none;
}

devii-terminal.devii-state-fullscreen .devii-window {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  resize: none;
}

/* On-screen keyboard inset: devii-terminal.js sets inline top/height from
   visualViewport so the window ends exactly at the keyboard top and the
   input row stays reachable. Drop the fixed bottom/height so the inline wins. */
devii-terminal.devii-keyboard-visible.devii-state-fullscreen .devii-window {
  bottom: auto;
  transition: none;
}

/* Title bar */
devii-terminal .devii-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 8px 12px;
  background: var(--devii-bar-bg);
  border-bottom: 1px solid var(--devii-border);
  flex: 0 0 auto;
  user-select: none;
}

devii-terminal .devii-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--devii-accent);
  font-weight: bold;
  letter-spacing: 0.5px;
}

devii-terminal .devii-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--devii-accent);
}

devii-terminal .devii-winctl button {
  background: transparent;
  color: var(--devii-dim);
  border: none;
  width: 28px;
  height: 24px;
  margin-left: 2px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

devii-terminal .devii-winctl button[hidden] {
  display: none;
}

devii-terminal .devii-winctl button:hover {
  color: var(--devii-fg);
  background: var(--devii-hover-bg);
}

devii-terminal .devii-winctl button[data-win="close"]:hover {
  background: var(--danger);
  color: var(--white);
}

/* Toolbar */
devii-terminal .devii-toolbar {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  background: var(--devii-toolbar-bg);
  border-bottom: 1px solid var(--devii-border);
  flex: 0 0 auto;
}

devii-terminal .devii-toolbar button {
  background: transparent;
  color: var(--devii-dim);
  border: 1px solid var(--devii-border);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

devii-terminal .devii-toolbar button:hover {
  color: var(--devii-fg);
  border-color: var(--devii-dim);
}

/* Body */
devii-terminal .devii-output {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
devii-terminal .devii-titlebar,
devii-terminal .devii-toolbar,
devii-terminal .devii-launcher,
devii-terminal .devii-prompt {
  user-select: none;
  -webkit-user-select: none;
}

devii-terminal .devii-line {
  margin: 2px 0;
  white-space: pre-wrap;
}

devii-terminal .devii-interaction-line {
  white-space: normal;
  overflow: visible;
  max-width: 100%;
  padding-bottom: 8px;
}

devii-terminal .devii-interaction-line ai-interaction,
devii-terminal .devii-interaction-line .ai-interaction {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

devii-terminal .devii-user {
  color: var(--devii-user);
}
devii-terminal .devii-agent {
  color: var(--devii-agent);
  white-space: normal;
  margin: 8px 0;
}
devii-terminal .devii-notice {
  color: var(--devii-dim);
}
devii-terminal .devii-trace {
  color: var(--devii-dim);
  font-size: 13px;
}
devii-terminal .devii-error {
  color: var(--devii-error);
}
devii-terminal .devii-task {
  color: var(--devii-task);
}

devii-terminal .devii-inputrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--devii-border);
  background: var(--devii-bar-bg);
  flex: 0 0 auto;
}

devii-terminal .devii-prompt {
  color: var(--devii-accent);
  flex: 0 0 auto;
}

devii-terminal .devii-input {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  outline: none;
  color: var(--devii-fg);
  font-family: inherit;
  font-size: inherit;
}

/* Markdown */
devii-terminal .devii-agent h1,
devii-terminal .devii-agent h2,
devii-terminal .devii-agent h3,
devii-terminal .devii-agent h4,
devii-terminal .devii-agent h5,
devii-terminal .devii-agent h6 {
  margin: 0.4em 0 0.2em;
  color: var(--white);
  line-height: 1.3;
}
devii-terminal .devii-agent p {
  margin: 0.3em 0;
}
devii-terminal .devii-agent a {
  color: var(--devii-link);
}
devii-terminal .devii-agent ul,
devii-terminal .devii-agent ol {
  margin: 0.3em 0;
  padding-left: 1.4em;
}
devii-terminal .devii-agent blockquote {
  margin: 0.3em 0;
  padding-left: 10px;
  border-left: 3px solid var(--devii-border);
  color: var(--devii-dim);
}
devii-terminal .devii-agent hr {
  border: none;
  border-top: 1px solid var(--devii-border);
  margin: 0.6em 0;
}
devii-terminal .md-code {
  background: var(--devii-code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--devii-code-fg);
}
devii-terminal .md-codewrap {
  position: relative;
}
devii-terminal .md-pre {
  background: var(--devii-code-bg);
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--devii-border);
  overflow-x: auto;
  margin: 0.5em 0;
}
devii-terminal .md-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 0.5;
  transition: opacity 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  background: var(--devii-bar-bg);
  color: var(--devii-fg);
  border: 1px solid var(--devii-border);
  border-radius: 5px;
  padding: 2px 9px;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.5;
  cursor: pointer;
  user-select: none;
  z-index: 2;
}
devii-terminal .md-codewrap:hover .md-copy,
devii-terminal .md-copy:focus-visible {
  opacity: 1;
}
devii-terminal .md-copy:hover {
  border-color: var(--devii-accent);
  color: var(--white);
}
devii-terminal .md-copy.md-copied {
  color: var(--devii-accent);
  border-color: var(--devii-accent);
  opacity: 1;
}

/* Per-message copy (copies the markdown source of the whole message) */
devii-terminal .devii-agent,
devii-terminal .devii-user,
devii-terminal .devii-task {
  position: relative;
}
devii-terminal .devii-copy {
  position: absolute;
  top: 3px;
  right: 6px;
  opacity: 0;
  transition: opacity 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  background: var(--devii-bar-bg);
  color: var(--devii-dim);
  border: 1px solid var(--devii-border);
  border-radius: 5px;
  padding: 1px 8px;
  font-family: inherit;
  font-size: 10px;
  line-height: 1.6;
  cursor: pointer;
  user-select: none;
  z-index: 3;
}
devii-terminal .devii-agent:hover > .devii-copy,
devii-terminal .devii-user:hover > .devii-copy,
devii-terminal .devii-task:hover > .devii-copy,
devii-terminal .devii-copy:focus-visible {
  opacity: 0.6;
}
devii-terminal .devii-copy:hover {
  opacity: 1;
  border-color: var(--devii-accent);
  color: var(--white);
}
devii-terminal .devii-copy.md-copied {
  opacity: 1;
  color: var(--devii-accent);
  border-color: var(--devii-accent);
}
devii-terminal .md-pre code {
  background: none;
  padding: 0;
  color: var(--devii-fg);
}
devii-terminal .tok-kw {
  color: var(--devii-tok-kw);
}
devii-terminal .tok-str {
  color: var(--devii-tok-str);
}
devii-terminal .tok-com {
  color: var(--devii-dim);
  font-style: italic;
}
devii-terminal .tok-num {
  color: var(--devii-tok-num);
}
devii-terminal .tok-lit {
  color: var(--devii-tok-lit);
}
devii-terminal .devii-agent .md-table {
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 0.82em;
  line-height: 1.35;
  max-width: 100%;
  display: block;
  overflow-x: auto;
}
devii-terminal .devii-agent .md-table th,
devii-terminal .devii-agent .md-table td {
  border: 1px solid var(--devii-border);
  padding: 3px 8px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
devii-terminal .devii-agent .md-table thead th {
  background: var(--devii-bar-bg);
  color: var(--white);
  font-weight: 600;
}
devii-terminal .devii-agent .md-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
devii-terminal .devii-agent .md-img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 0.4em 0;
  display: block;
}

/* Mobile: only close is available; window is forced fullscreen by JS */
devii-terminal.devii-mobile .devii-winctl button[data-win="minimize"],
devii-terminal.devii-mobile .devii-winctl button[data-win="normalize"],
devii-terminal.devii-mobile .devii-winctl button[data-win="maximize"],
devii-terminal.devii-mobile .devii-winctl button[data-win="fullscreen"] {
  display: none;
}

@media (max-width: 768px) {
  devii-terminal {
    --devii-font-size: 13px;
  }
  devii-terminal .devii-launcher {
    right: 14px;
    bottom: 14px;
    padding: 9px 16px;
  }
  devii-terminal .devii-winctl button {
    width: 34px;
    height: 30px;
    font-size: 16px;
  }
  devii-terminal .devii-inputrow {
    min-height: 44px;
  }
  devii-terminal .devii-input {
    min-height: 44px;
    font-size: 16px;
  }
}

/* Devii client-side tutorial overlays (attached to document.body) */
.devii-hl-box {
  position: fixed;
  z-index: 2147483600;
  border-radius: 6px;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.9), 0 0 18px 4px rgba(63, 185, 80, 0.55);
  transition: left 0.15s ease, top 0.15s ease, width 0.15s ease, height 0.15s ease;
}
.devii-hl-callout {
  position: fixed;
  z-index: 2147483601;
  max-width: 280px;
  background: var(--devii-bar-bg);
  color: var(--devii-agent);
  border: 1px solid var(--devii-accent);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.devii-toast {
  position: fixed;
  z-index: 2147483602;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: var(--devii-bar-bg);
  color: var(--devii-agent);
  border: 1px solid var(--devii-accent);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  max-width: 80vw;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.devii-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
