:root {
  color-scheme: dark;
  --bg: #050712;
  --panel: #0b1020;
  --panel-2: #101629;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f5f7ff;
  --muted: #9aa7c7;
  --accent: #4f7cff;
  --accent-2: #22c55e;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% -20%, rgba(79, 124, 255, 0.18), transparent 34rem),
    linear-gradient(180deg, #070915, var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.kicker {
  margin: 0 0 8px;
  color: #b8c7ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.lead {
  max-width: 700px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.health {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.health.ok {
  color: #bfffd2;
  border-color: rgba(34, 197, 94, 0.35);
}

.health.bad {
  color: #ffd1d1;
  border-color: rgba(255, 107, 107, 0.35);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(11, 16, 32, 0.82);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel-head p {
  color: var(--muted);
  line-height: 1.5;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(2, 4, 12, 0.62);
  outline: none;
}

input {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  padding: 13px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: rgba(79, 124, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.15);
}

.check-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.03);
}

.check-row input {
  width: auto;
  min-height: 0;
}

.check-row span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.primary {
  border-color: rgba(79, 124, 255, 0.7);
  background: linear-gradient(135deg, #244dff, #1730a5);
  font-weight: 800;
}

.ghost {
  background: rgba(255, 255, 255, 0.05);
}

.wide {
  width: 100%;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
}

.tools {
  display: grid;
  align-content: start;
  gap: 14px;
}

.tool-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.tool-card p {
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

#fileInput {
  display: none;
}

.chat-panel {
  min-height: 620px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(2, 4, 12, 0.42);
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 20px;
  display: grid;
  align-content: start;
  gap: 16px;
}

.message {
  max-width: min(760px, 100%);
}

.message.user {
  justify-self: end;
}

.message.agent,
.message.system {
  justify-self: start;
}

.message-meta {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-body {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user .message-body {
  border-color: rgba(79, 124, 255, 0.42);
  background: rgba(79, 124, 255, 0.12);
}

.message.system .message-body {
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: rgba(11, 16, 32, 0.9);
}

.composer textarea {
  min-height: 54px;
  max-height: 180px;
}

.log {
  min-height: 42px;
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  color: #c7d2fe;
  background: rgba(0, 0, 0, 0.25);
  white-space: pre-wrap;
  overflow: auto;
}

.log.compact {
  min-height: 80px;
  max-height: 180px;
  margin-top: 0;
  font-size: 12px;
}

@media (max-width: 900px) {
  .hero,
  .panel-head {
    display: grid;
  }

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

  .chat-panel {
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding: 18px 0;
  }

  .panel {
    padding: 14px;
    border-radius: 18px;
  }

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

  .button-row {
    grid-template-columns: 1fr;
  }
}
