:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-2: #0b0e14;
  --surface: rgba(18, 23, 33, 0.82);
  --surface-2: rgba(24, 30, 42, 0.9);
  --surface-3: rgba(255, 255, 255, 0.055);
  --line: rgba(226, 235, 255, 0.09);
  --line-strong: rgba(226, 235, 255, 0.16);
  --text: #eef4ff;
  --muted: #96a3b7;
  --muted-2: #667287;
  --accent: #5cc8ff;
  --accent-2: #7e8cff;
  --success: #54e39a;
  --warning: #ffd166;
  --danger: #ff6d7e;
  --command: #b8a7ff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.46);
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 20px;
  --top-safe: env(safe-area-inset-top, 0px);
  --bottom-safe: env(safe-area-inset-bottom, 0px);
  --nav-height: 76px;
  --topbar-height: 66px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(145deg, rgba(92, 200, 255, 0.11), transparent 34%),
    linear-gradient(215deg, rgba(126, 140, 255, 0.1), transparent 32%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 62%, #05070a 100%);
  color: var(--text);
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.boot-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
}

.boot-screen h1 {
  margin: 0;
  font-size: 24px;
}

.boot-screen p {
  margin: 8px 0 0;
  color: var(--muted);
}

.boot-mark,
.brand-mark {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(92, 200, 255, 0.96), rgba(126, 140, 255, 0.92)),
    #111827;
  box-shadow: 0 16px 42px rgba(92, 200, 255, 0.18);
}

.boot-mark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
}

.workspace {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(12px + var(--top-safe)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 9, 13, 0.97), rgba(7, 9, 13, 0.76));
  backdrop-filter: blur(20px);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 14px;
}

.brand-mark span {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(5, 12, 18, 0.82);
  border-radius: 6px;
  position: relative;
}

.brand-mark span::after {
  content: "";
  position: absolute;
  inset: 3px -6px -6px 3px;
  border-right: 2px solid rgba(5, 12, 18, 0.7);
  border-bottom: 2px solid rgba(5, 12, 18, 0.7);
  border-radius: 5px;
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions .badge {
  display: none;
}

.page {
  min-width: 0;
  padding: 16px 14px calc(var(--nav-height) + var(--bottom-safe) + 18px);
}

body[data-screen="chat"] {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body[data-screen="chat"] .workspace {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body[data-screen="chat"] .page {
  height: calc(100dvh - var(--topbar-height) - var(--nav-height) - var(--bottom-safe));
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

.screen {
  display: none;
  animation: fade-in 180ms ease both;
}

.screen.active {
  display: block;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 2px 14px;
}

.section-header.compact {
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.14;
  letter-spacing: 0;
}

.section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid,
.task-list,
.mini-list,
.detail-stack {
  display: grid;
  gap: 12px;
}

.panel,
.hero-card,
.task-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 14px;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 17px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(92, 200, 255, 0.15), rgba(126, 140, 255, 0.07) 58%, rgba(255, 255, 255, 0.025)),
    rgba(16, 20, 29, 0.9);
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, black, transparent 76%);
  pointer-events: none;
}

.hero-card > * {
  position: relative;
}

.hero-top,
.task-head,
.file-row,
.compact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hero-top {
  align-items: flex-start;
  justify-content: space-between;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.hero-card h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-card p {
  max-width: 28rem;
  margin: 9px 0 0;
  color: #b6c2d5;
  font-size: 14px;
  line-height: 1.45;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.metric {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 5px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.035);
}

.mini-dot.online,
.mini-dot.active,
.mini-dot.success,
.mini-dot.completed {
  background: var(--success);
}

.mini-dot.running,
.mini-dot.command,
.mini-dot.reconnecting {
  background: var(--accent);
  animation: pulse 1.3s ease-in-out infinite;
}

.mini-dot.offline,
.mini-dot.failed,
.mini-dot.error {
  background: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.65;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-tile,
.compact-row,
.file-row,
.chip-button,
.text-button,
.icon-button,
.nav-item,
.prompt-chips button {
  cursor: pointer;
  transition:
    transform 170ms ease,
    border-color 170ms ease,
    background 170ms ease,
    color 170ms ease,
    opacity 170ms ease;
}

.action-tile {
  min-height: 96px;
  display: grid;
  align-content: space-between;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.048);
  padding: 12px;
  text-align: left;
}

.action-tile span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: rgba(92, 200, 255, 0.1);
}

.action-tile strong {
  font-size: 14px;
}

.action-tile small,
.row-copy small,
.viewer-head small,
.task-foot {
  color: var(--muted);
  font-size: 12px;
}

.action-tile:active,
.compact-row:active,
.file-row:active,
.chip-button:active,
.text-button:active,
.icon-button:active,
.nav-item:active,
.prompt-chips button:active {
  transform: scale(0.97);
}

.icon-button {
  min-width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  display: grid;
  place-items: center;
}

.icon-button.subtle {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.send-button {
  color: #061019;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.chip-button,
.text-button,
.prompt-chips button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.052);
  padding: 0 12px;
  white-space: nowrap;
}

.chip-button svg,
.text-button svg,
.prompt-chips svg {
  width: 16px;
  height: 16px;
}

.chip-button.danger {
  color: #ffc8cf;
  border-color: rgba(255, 109, 126, 0.24);
  background: rgba(255, 109, 126, 0.09);
}

.text-button {
  min-height: 32px;
  color: var(--accent);
  border-color: transparent;
  background: transparent;
}

.badge {
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  font-size: 12px;
  white-space: nowrap;
}

.badge span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.online,
.badge.active,
.badge.completed,
.badge.success {
  color: #baf8d4;
  border-color: rgba(84, 227, 154, 0.28);
  background: rgba(84, 227, 154, 0.1);
}

.badge.running,
.badge.command {
  color: #b9edff;
  border-color: rgba(92, 200, 255, 0.3);
  background: rgba(92, 200, 255, 0.11);
}

.badge.warning,
.badge.waiting,
.badge.waiting_input,
.badge.queued {
  color: #ffe4a6;
  border-color: rgba(255, 209, 102, 0.3);
  background: rgba(255, 209, 102, 0.1);
}

.badge.failed,
.badge.error,
.badge.offline,
.badge.cancelled {
  color: #ffc1c9;
  border-color: rgba(255, 109, 126, 0.3);
  background: rgba(255, 109, 126, 0.1);
}

.compact-row {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.042);
  padding: 10px;
  text-align: left;
}

.compact-row.static {
  cursor: default;
}

.row-copy {
  min-width: 0;
  flex: 1;
}

.row-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.row-copy small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-type {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--accent);
  background: rgba(92, 200, 255, 0.1);
  font-size: 11px;
  font-weight: 800;
}

.file-type svg {
  width: 18px;
  height: 18px;
}

.file-type.dir {
  color: #ffd789;
  background: rgba(255, 209, 102, 0.12);
}

.file-type.config {
  color: #b8a7ff;
  background: rgba(184, 167, 255, 0.12);
}

.file-type.doc {
  color: #9ee8c1;
  background: rgba(84, 227, 154, 0.1);
}

.file-type.script {
  color: #ffb2bd;
  background: rgba(255, 109, 126, 0.1);
}

.file-type.user {
  color: #071019;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.file-type.system,
.file-type.assistant,
.file-type.task {
  color: var(--accent);
}

.file-type.running {
  animation: pulse 1.35s infinite;
}

.file-type.completed,
.file-type.success {
  color: var(--success);
  background: rgba(84, 227, 154, 0.1);
}

.file-type.failed,
.file-type.error {
  color: var(--danger);
  background: rgba(255, 109, 126, 0.1);
}

.active-panel .empty-state {
  padding: 22px 16px;
}

.message-list {
  display: grid;
  gap: 13px;
  padding-bottom: 180px;
}

.chat-screen {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-screen .section-header {
  flex: 0 0 auto;
}

.chat-screen .message-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 172px;
  scrollbar-width: none;
}

.chat-screen .message-list::-webkit-scrollbar {
  display: none;
}

.message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  max-width: 96%;
  animation: fade-in 180ms ease both;
}

.message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
  margin-left: auto;
}

.message.user .avatar {
  grid-column: 2;
  grid-row: 1;
}

.message.user .message-content {
  grid-column: 1;
  grid-row: 1;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.055);
}

.message.user .avatar {
  color: #061019;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

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

.message-meta {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.message.user .message-meta {
  text-align: right;
}

.bubble {
  overflow-wrap: anywhere;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  line-height: 1.48;
}

.message.user .bubble {
  color: #061019;
  border-color: rgba(92, 200, 255, 0.28);
  background: linear-gradient(135deg, rgba(92, 200, 255, 0.96), rgba(126, 140, 255, 0.93));
}

.message.system,
.message.error {
  max-width: 100%;
}

.message.system .bubble {
  color: #c0ccdc;
  background: rgba(255, 255, 255, 0.042);
}

.message.error .bubble {
  color: #ffc4cb;
  border-color: rgba(255, 109, 126, 0.24);
  background: rgba(255, 109, 126, 0.09);
}

.bubble p {
  margin: 0;
}

.bubble p + p {
  margin-top: 10px;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing 1.2s ease-in-out infinite;
}

.typing i:nth-child(2) {
  animation-delay: 120ms;
}

.typing i:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes typing {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.code-block {
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #05070a;
}

.code-block header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
}

.code-block pre {
  max-height: 56vh;
  margin: 0;
  overflow: auto;
  padding: 12px;
  color: #dce7f7;
  font: 12.5px/1.58 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  color: var(--accent);
  background: transparent;
  padding: 0;
  font-size: 12px;
}

.copy-button svg {
  width: 14px;
  height: 14px;
}

.composer-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-height) + var(--bottom-safe));
  z-index: 22;
  padding: 18px 12px 10px;
  background: linear-gradient(180deg, transparent, rgba(7, 9, 13, 0.95) 30%);
}

body[data-screen="chat"] .composer-wrap {
  transform: translateZ(0);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: rgba(15, 19, 28, 0.96);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(20px);
}

.composer:focus-within {
  border-color: rgba(92, 200, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(92, 200, 255, 0.09), 0 18px 56px rgba(0, 0, 0, 0.52);
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 132px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  padding: 10px 4px;
  line-height: 1.38;
}

.composer textarea::placeholder,
.search-box input::placeholder {
  color: #69758a;
}

.prompt-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 2px 0;
  scrollbar-width: none;
}

.prompt-chips::-webkit-scrollbar {
  display: none;
}

.prompt-chips button {
  min-height: 31px;
  color: var(--muted);
  font-size: 12px;
}

.file-toolbar {
  position: sticky;
  top: calc(62px + var(--top-safe));
  z-index: 12;
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  background: linear-gradient(180deg, rgba(7, 9, 13, 0.96), rgba(7, 9, 13, 0));
}

.search-box {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
  padding: 0 12px;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  color: var(--muted);
  font-size: 12px;
  scrollbar-width: none;
}

.breadcrumbs::-webkit-scrollbar {
  display: none;
}

.breadcrumbs span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list {
  display: grid;
  gap: 8px;
}

.file-row {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  padding: 10px;
  text-align: left;
}

.file-row.active {
  border-color: rgba(92, 200, 255, 0.42);
  background: rgba(92, 200, 255, 0.09);
}

.file-row > svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.task-card {
  padding: 14px;
}

.task-card p {
  margin: 11px 0 13px;
  color: #aab6c8;
  font-size: 13px;
  line-height: 1.45;
}

.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.075);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.task-card.completed .progress span,
.task-card.success .progress span {
  background: linear-gradient(90deg, var(--success), #9ee8c1);
}

.task-card.failed .progress span,
.task-card.error .progress span {
  background: linear-gradient(90deg, var(--danger), #ffafba);
}

.task-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.task-actions,
.viewer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.terminal-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #05070a;
  box-shadow: var(--shadow);
}

.terminal-bar {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.terminal-bar span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}

.terminal-bar span:nth-child(2) {
  background: var(--warning);
}

.terminal-bar span:nth-child(3) {
  background: var(--success);
}

.terminal-bar strong {
  margin-left: 4px;
  color: var(--muted);
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.terminal {
  min-height: 58vh;
  max-height: calc(100vh - 226px);
  overflow: auto;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.024), transparent),
    #05070a;
  font: 12px/1.56 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.mini-terminal {
  min-height: 160px;
  max-height: 260px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.log-line {
  display: block;
  padding: 2px 0;
  color: #bdc8d8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-line.info {
  color: #b6c6db;
}

.log-line.warning {
  color: var(--warning);
}

.log-line.error,
.log-line.failed {
  color: var(--danger);
}

.log-line.success,
.log-line.completed {
  color: var(--success);
}

.log-line.command,
.log-line.running {
  color: var(--command);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 32;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  min-height: calc(var(--nav-height) + var(--bottom-safe));
  padding: 8px 8px calc(8px + var(--bottom-safe));
  border-top: 1px solid var(--line);
  background: rgba(7, 9, 13, 0.93);
  backdrop-filter: blur(20px);
}

.nav-item {
  min-width: 0;
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 17px;
  color: var(--muted);
  background: transparent;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item span {
  font-size: 11px;
}

.nav-item.active {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(92, 200, 255, 0.13), rgba(126, 140, 255, 0.08)),
    rgba(255, 255, 255, 0.04);
}

.nav-item.active svg {
  color: var(--accent);
}

.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(7px);
}

.bottom-sheet.open {
  display: flex;
}

.sheet-panel {
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  padding: 10px 14px calc(18px + var(--bottom-safe));
  border: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  background: #0d1119;
  box-shadow: var(--shadow);
  animation: sheet-up 200ms ease both;
}

@keyframes sheet-up {
  from {
    transform: translateY(22px);
  }
  to {
    transform: translateY(0);
  }
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 0 auto 13px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
}

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.viewer-head div {
  min-width: 0;
}

.viewer-head strong,
.viewer-head small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h3 {
  margin: 0;
  font-size: 15px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  background: linear-gradient(180deg, transparent, #0d1119 40%);
}

.empty-state,
.error-state {
  display: grid;
  gap: 8px;
  place-items: center;
  padding: 30px 18px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong,
.error-state strong {
  color: var(--text);
}

.empty-state span,
.error-state span {
  max-width: 24rem;
  font-size: 13px;
  line-height: 1.42;
}

.state-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--accent);
  background: rgba(92, 200, 255, 0.1);
}

.state-icon.danger {
  color: var(--danger);
  background: rgba(255, 109, 126, 0.09);
}

.skeleton {
  position: relative;
  overflow: hidden;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
}

.skeleton.row-skeleton {
  min-height: 58px;
}

.skeleton.message-skeleton {
  width: 88%;
  min-height: 90px;
}

.skeleton.terminal-skeleton {
  min-height: 64px;
  background: rgba(255, 255, 255, 0.035);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  animation: shimmer 1.35s infinite;
}

@keyframes shimmer {
  to {
    transform: translateX(100%);
  }
}

.icon-button:focus-visible,
.nav-item:focus-visible,
.chip-button:focus-visible,
.text-button:focus-visible,
.file-row:focus-visible,
.compact-row:focus-visible,
.action-tile:focus-visible,
.prompt-chips button:focus-visible,
.search-box:focus-within {
  outline: 2px solid rgba(92, 200, 255, 0.55);
  outline-offset: 2px;
}

@media (hover: hover) {
  .action-tile:hover,
  .compact-row:hover,
  .file-row:hover,
  .chip-button:hover,
  .icon-button:hover,
  .prompt-chips button:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.075);
  }
}

@media (min-width: 520px) {
  .topbar-actions .badge {
    display: inline-flex;
  }
}

@media (min-width: 820px) {
  :root {
    --nav-height: 0px;
  }

  .workspace {
    grid-template-columns: 92px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .topbar {
    grid-column: 2;
  }

  .page {
    grid-column: 2;
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding-bottom: 24px;
  }

  .bottom-nav {
    top: 0;
    right: auto;
    width: 92px;
    height: 100vh;
    grid-template-columns: 1fr;
    grid-auto-rows: 72px;
    align-content: center;
    border-top: 0;
    border-right: 1px solid var(--line);
  }

  .composer-wrap {
    left: 92px;
    bottom: 0;
    max-width: 1080px;
    margin: 0 auto;
  }

  .dashboard-grid {
    grid-template-columns: 1.18fr 0.82fr;
  }

  .hero-card,
  .active-panel {
    grid-column: span 1;
  }

  .terminal {
    max-height: calc(100vh - 180px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Telegram WebView is more reliable with document-level scrolling than nested
   fixed scroll containers. Chat keeps the composer fixed, but the history
   itself scrolls like a normal page. */
body[data-screen="chat"],
body[data-screen="chat"] .workspace {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

body[data-screen="chat"] .page {
  height: auto;
  min-height: 0;
  overflow: visible;
  padding-bottom: calc(var(--nav-height) + var(--bottom-safe) + 190px);
}

body[data-screen="chat"] .chat-screen {
  height: auto;
  min-height: 0;
  display: block;
  overflow: visible;
}

body[data-screen="chat"] .chat-screen .message-list {
  display: grid;
  overflow: visible;
  padding-bottom: 0;
}
