:root {
  --bg: #0c1118;
  --border: #243041;
  --border-soft: rgba(148, 174, 204, 0.12);
  --text: #e8eef6;
  --dim: #8fa3b8;
  --mute: #5c7086;
  --accent: #3dffa8;
  --ai: #6ec8ff;
  --ds: #9b8cff;
  --danger: #ff6b6b;
  --ok: #3dffa8;
  --font: "Sora", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --bar-h: 52px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.ds-app {
  display: grid;
  grid-template-rows: var(--bar-h) 1fr;
  height: 100%;
  background:
    radial-gradient(900px 400px at 70% -10%, rgba(155, 140, 255, 0.1), transparent 50%),
    linear-gradient(180deg, #0e141d, var(--bg));
}

.ds-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(12, 17, 24, 0.85);
  backdrop-filter: blur(10px);
}

.ds-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ds-brand__mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: url("/static/img/logo.png") center / contain no-repeat;
  flex-shrink: 0;
}

.ds-brand__name {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 13px;
}

.ds-brand__tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ds);
  padding: 3px 7px;
  border: 1px solid rgba(155, 140, 255, 0.4);
  border-radius: 6px;
}

.ds-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ds-filename {
  width: 150px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0c1118;
  font-size: 12px;
  font-family: var(--mono);
}

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}

.ds-btn--ghost {
  border-color: var(--border);
  color: var(--dim);
}

.ds-btn--ghost:hover {
  color: var(--text);
  border-color: rgba(148, 174, 204, 0.35);
}

.ds-btn--primary {
  background: var(--ds);
  color: #120f22;
}

.ds-btn--primary:hover {
  filter: brightness(1.06);
}

.ds-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ds-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.ds-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px 18px;
  overflow: auto;
}

.ds-panel:first-child {
  border-right: 1px solid var(--border-soft);
}

.ds-panel--out {
  overflow: hidden;
}

.ds-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.ds-panel__head h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.ds-hint {
  font-size: 11px;
  color: var(--mute);
}

.ds-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ds-field span {
  font-size: 12px;
  color: var(--dim);
  font-weight: 500;
}

.ds-field input,
.ds-field textarea,
.ds-field select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0c1118;
  outline: none;
}

.ds-field textarea {
  resize: vertical;
  line-height: 1.5;
  font-size: 13px;
}

.ds-field input:focus,
.ds-field textarea:focus,
.ds-field select:focus {
  border-color: rgba(155, 140, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(155, 140, 255, 0.12);
}

.ds-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ds-schema {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--mute);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(155, 140, 255, 0.3);
  background: rgba(155, 140, 255, 0.05);
  word-break: break-all;
}

.ds-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ds-actions .ai-model-select {
  margin-left: auto;
}

.ds-status {
  font-size: 12px;
  color: var(--mute);
  min-height: 1.2em;
}

.ds-status.is-ok { color: var(--ok); }
.ds-status.is-err { color: var(--danger); }

.ds-raw {
  flex: 1;
  min-height: 180px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0c1118;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  resize: none;
  outline: none;
}

.ds-raw:focus {
  border-color: rgba(155, 140, 255, 0.45);
}

.ds-preview {
  margin-top: 10px;
  max-height: 42%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ds-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: rgba(17, 24, 33, 0.8);
  font-size: 12px;
  line-height: 1.45;
  color: var(--dim);
  animation: ds-in 0.25s ease both;
}

.ds-card__i {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ds);
  margin-bottom: 4px;
}

.ds-card strong {
  color: var(--text);
  font-weight: 600;
}

@keyframes ds-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 900px) {
  .ds-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .ds-panel:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
    max-height: 48%;
  }

  .ds-bar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 12px;
    gap: 8px;
  }

  .ds-bar button,
  .ds-bar .icon-btn {
    min-height: 40px;
  }

  .ds-app {
    grid-template-rows: auto 1fr;
  }
}

@media (max-width: 640px) {
  .ds-panel:first-child {
    max-height: 40%;
  }
}
