:root {
  color-scheme: dark;
  --bg: #07090f;
  --surface: #101522;
  --surface-strong: #171f31;
  --surface-hot: #1d2638;
  --text: #f6fbff;
  --muted: #a7b4c7;
  --border: rgba(156, 239, 255, 0.22);
  --primary: #00e5ff;
  --primary-text: #061018;
  --agent-accent: #00e5ff;
  --danger: #ff477e;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(0, 229, 255, 0.08), transparent 220px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 80px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

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

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(0, 229, 255, 0.55);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.26), rgba(182, 255, 77, 0.16));
  color: var(--text);
  font-weight: 900;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.22);
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 30px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--primary);
}

.workspace {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  padding: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 800;
}

.section-title small {
  color: var(--muted);
  font-weight: 600;
}

.agent-list,
.template-list,
.history-list {
  display: grid;
  gap: 10px;
}

.agent-card,
.template-card,
.history-card,
textarea,
.answer,
.empty {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
}

.agent-card,
.template-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.agent-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.agent-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 3px solid var(--agent-accent);
  opacity: 0.7;
  pointer-events: none;
}

.agent-card:hover,
.agent-card.active {
  border-color: var(--agent-accent);
  background: color-mix(in srgb, var(--agent-accent) 14%, var(--surface-strong));
}

.agent-card.active {
  box-shadow: 0 0 22px color-mix(in srgb, var(--agent-accent) 22%, transparent);
}

.agent-card-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.agent-card strong,
.template-card strong,
.history-card strong {
  display: block;
  margin-bottom: 0;
}

.agent-card span,
.template-card span,
.history-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.agent-card em,
.role-label {
  color: var(--agent-accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.agent-avatar {
  display: inline-grid;
  place-items: center;
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--agent-accent) 70%, #ffffff);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--agent-accent) 24%, #111827), #0c101a);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.05), 0 0 18px color-mix(in srgb, var(--agent-accent) 24%, transparent);
  overflow: hidden;
}

.agent-avatar.large {
  width: 72px;
  height: 72px;
}

.agent-avatar.small {
  width: 36px;
  height: 36px;
}

.agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-symbol {
  color: var(--agent-accent);
  font-size: 26px;
  line-height: 1;
}

.agent-avatar.large .avatar-symbol {
  font-size: 40px;
}

.agent-avatar.small .avatar-symbol {
  font-size: 20px;
}

.avatar-initials {
  position: absolute;
  right: 5px;
  bottom: 4px;
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
}

.agent-hero {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--agent-accent) 34%, var(--border));
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--agent-accent) 14%, transparent), transparent),
    var(--surface-strong);
  margin-bottom: 12px;
}

.agent-hero h2 {
  margin-bottom: 5px;
  font-size: 24px;
}

.role-label {
  display: inline-flex;
  margin-bottom: 8px;
}

.agent-hero p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: var(--surface-hot);
  color: var(--text);
  font-size: 13px;
}

.templates {
  margin: 14px 0;
}

.template-card {
  padding: 12px;
}

.template-card:hover {
  border-color: var(--agent-accent);
}

.composer {
  display: grid;
  gap: 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 138px;
  padding: 12px;
  outline: none;
}

textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

textarea:focus {
  border-color: var(--agent-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--agent-accent) 18%, transparent);
}

.composer button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--agent-accent), #ffffff);
  color: var(--primary-text);
  font-weight: 900;
  cursor: pointer;
}

.composer button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.answer {
  white-space: pre-wrap;
  margin-top: 14px;
  padding: 14px;
  line-height: 1.45;
}

.history-tabs {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 8px;
  margin-bottom: 10px;
}

.tab-button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  cursor: pointer;
}

.tab-button.active {
  border-color: var(--agent-accent);
  color: var(--text);
  background: color-mix(in srgb, var(--agent-accent) 16%, var(--surface-strong));
}

.history-card {
  overflow: hidden;
}

.history-summary {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.history-copy {
  min-width: 0;
}

.history-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-details {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
}

.run-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.run-meta div {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.run-meta dt {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
}

.run-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.message-block {
  display: grid;
  gap: 6px;
}

.message-block strong {
  color: var(--text);
  font-size: 13px;
}

.message-block pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: #090d15;
  color: var(--text);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
  border-style: dashed;
  padding: 14px;
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .history-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 46px minmax(0, 1fr) 42px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  h1 {
    font-size: 26px;
  }

  .agent-hero {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .agent-avatar.large {
    width: 58px;
    height: 58px;
  }

  .run-meta {
    grid-template-columns: 1fr;
  }
}
