:root {
  color-scheme: dark;
  --bg: #080d12;
  --panel: #101820;
  --panel-raised: #14202a;
  --panel-soft: #0d151d;
  --field: #0b1118;
  --border: #263543;
  --border-strong: #3c5061;
  --text: #e7edf2;
  --muted: #91a3b4;
  --faint: #637586;
  --accent: #35d0a7;
  --accent-strong: #79ffe0;
  --accent-soft: rgba(53, 208, 167, 0.12);
  --blue: #6fb8ff;
  --blue-soft: rgba(111, 184, 255, 0.12);
  --danger: #ff6b76;
  --danger-soft: rgba(255, 107, 118, 0.13);
  --warning: #ffd166;
  --warning-soft: rgba(255, 209, 102, 0.12);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.26);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  min-width: 1200px;
  margin: 0;
  background:
    radial-gradient(circle at 16% -12%, rgba(53, 208, 167, 0.18), transparent 28rem),
    radial-gradient(circle at 86% 0%, rgba(111, 184, 255, 0.12), transparent 24rem),
    linear-gradient(180deg, #0b1118 0%, var(--bg) 42%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  display: grid;
  grid-template-rows: 76px 86px 54px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(60, 80, 97, 0.72);
  background: rgba(8, 13, 18, 0.84);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(53, 208, 167, 0.5);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(53, 208, 167, 0.28), rgba(111, 184, 255, 0.08)),
    #0d151d;
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 0 24px rgba(53, 208, 167, 0.16);
}

.brand h1,
.panel-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.15;
}

.brand p,
.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.brand p {
  font-size: 12px;
}

.command-center {
  display: flex;
  align-items: end;
  gap: 10px;
}

.select-control,
.field,
.toggle-field {
  display: grid;
  gap: 7px;
}

.select-control span,
.field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.select-control select {
  width: 260px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

select,
input {
  height: 42px;
  padding: 0 12px;
}

select {
  appearance: none;
  padding-right: 36px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 18px / 5px 5px
      no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) 18px / 5px 5px
      no-repeat,
    var(--field);
}

textarea {
  min-height: 112px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input[readonly] {
  color: var(--muted);
  background: rgba(11, 17, 24, 0.62);
}

select:hover,
input:hover,
textarea:hover {
  border-color: var(--border-strong);
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(53, 208, 167, 0.14);
}

textarea::placeholder,
input::placeholder {
  color: #566879;
}

.docs-link,
.icon-button,
.primary-button,
.secondary-button,
.copy-message,
.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.docs-link,
.icon-button,
.secondary-button,
.tab-button {
  background: rgba(16, 24, 32, 0.9);
  color: var(--text);
}

.docs-link {
  min-height: 42px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
}

.primary-button {
  min-height: 42px;
  padding: 0 16px;
  border-color: rgba(53, 208, 167, 0.52);
  background: linear-gradient(180deg, rgba(53, 208, 167, 0.28), rgba(53, 208, 167, 0.18));
  color: var(--accent-strong);
  font-weight: 850;
  box-shadow: 0 0 26px rgba(53, 208, 167, 0.08);
}

.secondary-button {
  min-height: 38px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 800;
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.docs-link:hover,
.icon-button:hover:not(:disabled),
.copy-message:hover:not(:disabled) {
  border-color: rgba(53, 208, 167, 0.58);
  background-color: rgba(53, 208, 167, 0.12);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.status-strip {
  display: grid;
  grid-template-columns: 150px 190px 190px 1fr 1fr;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid rgba(60, 80, 97, 0.54);
}

.status-card {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(60, 80, 97, 0.64);
  border-radius: var(--radius);
  background: rgba(16, 24, 32, 0.72);
}

.status-card span,
.selection-summary span,
.meta-label {
  display: block;
  color: var(--faint);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-card strong,
.selection-summary strong {
  display: block;
  min-width: 0;
  margin-top: 6px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ready,
.status-pill.ready {
  color: var(--accent-strong);
}

.blocked,
.status-pill.blocked {
  color: var(--danger);
}

.pending,
.status-pill.pending {
  color: var(--warning);
}

.tabbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  border-bottom: 1px solid rgba(60, 80, 97, 0.54);
}

.tab-button {
  min-width: 122px;
  min-height: 34px;
  font-size: 13px;
  font-weight: 850;
}

.tab-button.active {
  border-color: rgba(53, 208, 167, 0.55);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 -1px 0 rgba(53, 208, 167, 0.28);
}

.workspace {
  min-height: 0;
  padding: 18px 28px 28px;
}

.tab-panel {
  height: 100%;
  min-height: 0;
}

.tab-panel[hidden] {
  display: none;
}

.query-grid,
.management-grid,
.ingestion-grid,
.indexes-grid {
  display: grid;
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.query-grid {
  grid-template-columns: 320px minmax(0, 1fr);
}

.management-grid {
  grid-template-columns: minmax(0, 1fr);
}

.ingestion-grid {
  grid-template-columns: 520px minmax(0, 1fr);
}

.indexes-grid {
  grid-template-columns: minmax(0, 1fr);
}

.control-panel,
.chat-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(60, 80, 97, 0.7);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(20, 32, 42, 0.92), rgba(13, 21, 29, 0.94)),
    var(--panel);
  box-shadow: var(--shadow);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.panel-header h2 {
  font-size: 16px;
}

.panel-header p {
  font-size: 12px;
}

.query-controls {
  height: 100%;
}

.selection-summary {
  display: grid;
  gap: 10px;
  margin-top: 2px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(11, 17, 24, 0.58);
}

.chat-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.conversation {
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
}

.empty-state {
  margin: auto;
  max-width: 620px;
  padding: 28px;
  border: 1px dashed rgba(99, 117, 134, 0.58);
  border-radius: var(--radius);
  background: rgba(11, 17, 24, 0.46);
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 22px;
  letter-spacing: 0;
}

.empty-state p {
  margin: 0;
  line-height: 1.55;
}

.message {
  max-width: min(860px, 86%);
  padding: 14px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 24, 32, 0.92);
}

.message.user {
  align-self: flex-end;
  border-color: rgba(111, 184, 255, 0.36);
  background: var(--blue-soft);
}

.message.assistant,
.message.error,
.message.pending {
  align-self: flex-start;
}

.message.assistant {
  border-color: rgba(53, 208, 167, 0.24);
}

.message.pending {
  border-color: rgba(255, 209, 102, 0.32);
  background: var(--warning-soft);
  color: var(--warning);
}

.message.error {
  border-color: rgba(255, 107, 118, 0.38);
  background: var(--danger-soft);
}

.message-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-role {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-message {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--muted);
}

.copy-message svg {
  width: 15px;
  height: 15px;
}

.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.sources {
  margin-top: 13px;
  border-top: 1px solid rgba(60, 80, 97, 0.7);
  color: var(--muted);
}

.sources summary {
  padding-top: 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.sources ol {
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
  padding-left: 20px;
}

.sources li {
  padding: 10px;
  border: 1px solid rgba(60, 80, 97, 0.62);
  border-radius: var(--radius);
  background: rgba(11, 17, 24, 0.52);
}

.source-title {
  color: var(--text);
  font-weight: 850;
}

.source-content {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-height: 1.45;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(60, 80, 97, 0.68);
  background: rgba(8, 13, 18, 0.72);
}

.composer textarea {
  min-height: 48px;
  max-height: 180px;
  resize: none;
}

.send-button svg {
  width: 17px;
  height: 17px;
}

.form-panel {
  min-height: 620px;
}

.version-panel {
  min-height: 620px;
}

.modal-dialog {
  width: min(720px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.modal-dialog::backdrop {
  background: rgba(3, 7, 11, 0.72);
  backdrop-filter: blur(6px);
}

.create-agent-panel {
  min-height: 0;
  max-height: calc(100vh - 56px);
  overflow: auto;
}

.create-agent-panel .grow textarea {
  min-height: 240px;
}

.two-column,
.three-column {
  display: grid;
  gap: 12px;
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-column {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grow {
  flex: 1;
}

.grow textarea {
  height: 100%;
  min-height: 210px;
}

.toggle-field {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.toggle-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.run-view,
.index-list,
.agent-version-list {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.run-view {
  overflow: auto;
}

.run-card,
.index-card,
.agent-version-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(11, 17, 24, 0.62);
}

.run-card {
  display: grid;
  gap: 12px;
}

.run-card-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.run-card-title {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.run-field strong,
.index-title,
.agent-version-title {
  display: block;
  min-width: 0;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 850;
}

.run-message,
.run-result {
  padding: 12px;
  border: 1px solid rgba(60, 80, 97, 0.62);
  border-radius: var(--radius);
  background: rgba(16, 24, 32, 0.62);
  color: var(--muted);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.index-list,
.agent-version-list {
  overflow: auto;
}

.index-card,
.agent-version-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.index-title,
.agent-version-title {
  margin-top: 0;
  font-size: 15px;
}

.index-meta,
.agent-version-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.agent-version-card {
  cursor: pointer;
}

.agent-version-card.selected {
  border-color: rgba(53, 208, 167, 0.48);
  background: rgba(53, 208, 167, 0.09);
}

.agent-version-prompt {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.version-editor {
  display: grid;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid rgba(60, 80, 97, 0.7);
}

.version-editor[hidden] {
  display: none;
}

.index-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  min-width: 84px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.notice-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: 380px;
}

.notice {
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 24, 32, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.notice.success {
  border-color: rgba(53, 208, 167, 0.4);
}

.notice.error {
  border-color: rgba(255, 107, 118, 0.42);
}

.notice.info {
  border-color: rgba(111, 184, 255, 0.36);
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

@media (max-width: 1199px) {
  body::before {
    content: "Atlantis KMS Control Room is optimized for desktop widths of 1200px and above.";
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 32px;
    background: var(--bg);
    color: var(--text);
    font-size: 18px;
    text-align: center;
  }
}
