@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/Inter-Italic-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0a0f14;
  --panel: #111820;
  --panel-strong: #151f29;
  --border: #26313d;
  --border-strong: #3a4653;
  --text: #edf4f7;
  --muted: #98a8b6;
  --accent: #38d9a9;
  --accent-strong: #71e7c4;
  --danger: #ff6b6b;
  --warning: #ffd166;
  --shadow: rgba(0, 0, 0, 0.42);
  --ai-topbar-height: 44px;
  --ai-tabs-height: 36px;
}

* {
  box-sizing: border-box;
}

html,
body,
#ai-root {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 100dvh;
  margin: 0;
}

body {
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.ai-shell {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100dvh;
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(56, 217, 169, 0.08), transparent 160px),
    var(--bg);
}

.ai-chrome {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  right: 0;
  left: 0;
  z-index: 2147483000;
  display: block;
  background: #0a0f14;
  transform: translateZ(0);
  will-change: transform;
}

.ai-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--ai-topbar-height);
  min-height: 0;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  background: #0a0f14;
}

.ai-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ai-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(56, 217, 169, 0.45);
  border-radius: 8px;
  background: #0f171e;
  color: var(--accent);
  cursor: pointer;
  font-weight: 800;
  padding: 0;
}

.ai-mark:disabled {
  cursor: default;
  opacity: 0.55;
}

.ai-mark:hover:not(:disabled) {
  border-color: var(--accent);
  background: #14382f;
}

.ai-brand__copy {
  min-width: 0;
}

.ai-brand__title {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
}

.ai-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #15202a;
  color: var(--text);
  cursor: pointer;
}

.ai-button:hover {
  border-color: var(--accent);
}

.ai-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ai-button--primary {
  border-color: rgba(56, 217, 169, 0.65);
  background: #14382f;
  color: #eafff8;
}

.ai-button--danger {
  border-color: rgba(255, 107, 107, 0.55);
  background: #351c21;
}

.ai-tabs {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  gap: 4px;
  height: var(--ai-tabs-height);
  min-height: 0;
  padding: 5px 6px 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 20, 27, 0.96);
  scrollbar-width: none;
}

.ai-tabs::-webkit-scrollbar {
  display: none;
}

.ai-tab {
  display: inline-grid;
  grid-template-columns: minmax(60px, 190px) 26px;
  align-items: center;
  min-width: 118px;
  height: 31px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: #101821;
  color: var(--muted);
}

.ai-tab--new {
  display: grid;
  grid-template-columns: 1fr;
  min-width: 42px;
  width: 42px;
  place-items: center;
  border-bottom: 1px solid var(--border);
  border-radius: 7px;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.ai-tab--new:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ai-tab--new:hover:not(:disabled) {
  border-color: var(--accent);
  background: #14382f;
}

.ai-tab.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 -10px 22px var(--shadow);
}

.ai-tab__label,
.ai-tab__close {
  height: 100%;
  border: 0;
  background: transparent;
}

.ai-tab__label {
  min-width: 0;
  padding: 0 9px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.ai-tab__close {
  display: grid;
  place-items: center;
  color: var(--muted);
  cursor: pointer;
}

.ai-tab__close:hover {
  color: var(--danger);
}

.ai-main {
  position: fixed;
  top: calc(
    env(safe-area-inset-top, 0px) + var(--ai-topbar-height) +
      var(--ai-tabs-height)
  );
  right: 0;
  bottom: env(safe-area-inset-bottom, 0);
  left: 0;
  display: block;
  z-index: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--panel);
}

.ai-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.ai-status[data-state="connected"],
.ai-status[data-state="running"] {
  border-color: rgba(56, 217, 169, 0.55);
  color: var(--accent-strong);
}

.ai-status[data-state="error"],
.ai-status[data-state="killed"],
.ai-status[data-state="failed"] {
  border-color: rgba(255, 107, 107, 0.55);
  color: var(--danger);
}

.ai-terminal-stack {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #06090d;
}

.ai-terminal-pane {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: none;
  padding: 0;
  overflow: hidden;
}

.ai-terminal-pane.is-active {
  display: block;
}

.ai-terminal {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #06090d;
  overscroll-behavior: contain;
  touch-action: none;
}

.ai-empty {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.ai-empty__box {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding: 24px;
}

.ai-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 7, 10, 0.72);
}

.ai-rename {
  display: grid;
  width: min(420px, 100%);
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #111820;
  box-shadow: 0 20px 48px var(--shadow);
}

.ai-rename h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
}

.ai-rename__input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #0c131a;
  color: var(--text);
  padding: 0 10px;
}

.ai-rename__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ai-error {
  position: fixed;
  right: 14px;
  bottom: 14px;
  max-width: min(520px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 107, 107, 0.55);
  border-radius: 8px;
  background: #351c21;
  color: #ffe8e8;
  box-shadow: 0 16px 32px var(--shadow);
}

.xterm {
  height: 100%;
  padding: 6px;
  touch-action: none;
}

.xterm .xterm-viewport {
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-color: #415160 #080c10;
  scrollbar-width: auto;
  touch-action: none;
  -webkit-overflow-scrolling: touch;
}

.xterm .xterm-screen {
  touch-action: none;
}

.xterm .xterm-viewport::-webkit-scrollbar {
  width: 22px;
}

.xterm .xterm-viewport::-webkit-scrollbar-track {
  background: #080c10;
}

.xterm .xterm-viewport::-webkit-scrollbar-thumb {
  min-height: 56px;
  border: 4px solid #080c10;
  border-radius: 999px;
  background: #5c7082;
}

.xterm .xterm-viewport::-webkit-scrollbar-thumb:hover {
  background: #7890a5;
}

@media (max-width: 720px) {
  :root {
    --ai-topbar-height: 40px;
    --ai-tabs-height: 34px;
  }

  .ai-topbar {
    gap: 8px;
    padding: 0 8px;
  }

  .ai-tabs {
    padding-top: 4px;
  }

  .ai-actions {
    flex: 0 0 auto;
  }

  .ai-terminal-pane {
    padding: 0;
  }

  .xterm {
    padding: 4px;
  }
}
