:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #090a0c;
  color: #eceff3;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(65, 91, 255, 0.16), transparent 34rem),
    linear-gradient(180deg, #0d0f13 0%, #08090b 100%);
}

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

button {
  border: 1px solid #30343d;
  background: #181b20;
  color: #f4f6f8;
  border-radius: 8px;
  padding: 0.58rem 0.78rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #222730;
  border-color: #47505f;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #2d323b;
  border-radius: 8px;
  background: #111318;
  color: #f7f9fb;
  padding: 0.64rem 0.72rem;
  outline: none;
}

textarea {
  min-height: 9rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #6d7dff;
  box-shadow: 0 0 0 3px rgba(109, 125, 255, 0.16);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #20242b;
  background: rgba(9, 10, 12, 0.82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.mark {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 8px;
  background: #edeff3;
  color: #090a0c;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.2;
}

.brand p {
  margin: 0.1rem 0 0;
  color: #969da9;
  font-size: 0.82rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #aeb5c0;
  font-size: 0.84rem;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #51d88a;
  box-shadow: 0 0 0 4px rgba(81, 216, 138, 0.14);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1px;
  background: #20242b;
}

.sidebar,
.main {
  background: rgba(11, 12, 15, 0.96);
  min-height: calc(100vh - 4.4rem);
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.panel {
  padding: 1rem;
  border-bottom: 1px solid #20242b;
}

.panel h2,
.section-title {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9aa2ad;
}

.dropzone {
  border: 1px dashed #3a414d;
  border-radius: 8px;
  padding: 1rem;
  background: #111318;
  color: #cbd1da;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.dragging {
  border-color: #7e8bff;
  background: rgba(126, 139, 255, 0.13);
}

.dropzone strong {
  display: block;
  margin-bottom: 0.2rem;
}

.dropzone span {
  color: #8d95a3;
  font-size: 0.84rem;
}

.file-tree {
  overflow: auto;
  padding: 0.75rem;
}

.file-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 0.46rem 0.5rem;
  background: transparent;
  color: #dce1e7;
  text-align: left;
}

.file-row:hover,
.file-row.active {
  background: #171a20;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  color: #7f8794;
  font-size: 0.75rem;
}

.empty {
  color: #7f8794;
  font-size: 0.9rem;
  padding: 0.75rem 0.5rem;
}

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 320px) 1fr auto;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem;
  border-bottom: 1px solid #20242b;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  color: #98a1ad;
  font-size: 0.78rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 42%);
  min-height: 0;
}

.chat,
.preview {
  min-width: 0;
  min-height: 0;
}

.chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  border-right: 1px solid #20242b;
}

.messages {
  overflow: auto;
  padding: 1rem;
}

.message {
  max-width: 58rem;
  margin: 0 0 0.75rem;
  border-radius: 8px;
  padding: 0.82rem 0.9rem;
  background: #151820;
  border: 1px solid #252a33;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  background: #20243a;
  border-color: #333b76;
}

.message.error {
  background: #2b1518;
  border-color: #74343b;
}

.message.progress {
  background: #12151a;
  color: #abb3bf;
}

.composer {
  border-top: 1px solid #20242b;
  padding: 1rem;
  background: rgba(11, 12, 15, 0.98);
}

.schema-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.schema-grid .wide {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

.primary {
  background: #e9ecf2;
  color: #090a0c;
  border-color: #e9ecf2;
  font-weight: 700;
}

.primary:hover:not(:disabled) {
  background: #ffffff;
}

.preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid #20242b;
}

.preview-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-body {
  overflow: auto;
  padding: 1rem;
}

.preview-body img,
.preview-body video,
.preview-body audio,
.preview-body iframe {
  max-width: 100%;
}

.preview-body iframe {
  width: 100%;
  height: 72vh;
  border: 1px solid #252a33;
  border-radius: 8px;
  background: #fff;
}

pre {
  margin: 0;
  padding: 1rem;
  border-radius: 8px;
  background: #07080a;
  border: 1px solid #252a33;
  color: #e7ebf0;
  overflow: auto;
  white-space: pre-wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  border-bottom: 1px solid #242a33;
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: #cfd5de;
  background: #12151a;
  position: sticky;
  top: 0;
}

.muted {
  color: #88919e;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #303640;
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  color: #aeb6c2;
  font-size: 0.78rem;
}

.setup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(5, 6, 8, 0.76);
  backdrop-filter: blur(10px);
}

.setup-card {
  width: min(38rem, 100%);
  max-height: min(48rem, calc(100vh - 2.5rem));
  overflow: auto;
  border: 1px solid #303640;
  border-radius: 8px;
  background: #0d0f13;
  box-shadow: 0 1.4rem 4rem rgba(0, 0, 0, 0.38);
  padding: 1.25rem;
}

.setup-kicker {
  margin-bottom: 0.45rem;
  color: #9aa2ad;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.setup-card h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.setup-card > p {
  margin: 0.55rem 0 1rem;
  color: #9aa2ad;
  font-size: 0.9rem;
  line-height: 1.45;
}

.setup-group {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 0;
  border-top: 1px solid #20242b;
}

.setup-group h3 {
  margin: 0;
  color: #cfd5de;
  font-size: 0.86rem;
}

.setup-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
  color: #dce1e7;
  font-size: 0.84rem;
}

.setup-field label span {
  color: #8d95a3;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.setup-field p {
  margin: 0.35rem 0 0;
  color: #7f8794;
  font-size: 0.78rem;
  line-height: 1.35;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid #20242b;
}

@media (max-width: 980px) {
  .layout,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .main {
    min-height: auto;
  }

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

  .chat {
    min-height: 60vh;
    border-right: 0;
    border-bottom: 1px solid #20242b;
  }
}
