:root {
  --bg: #07111f;
  --panel: #111c2d;
  --panel-2: #0d1625;
  --surface: #0b1422;
  --surface-2: #121d2c;
  --border: #23344d;
  --border-2: #324964;
  --text: #e8f0fb;
  --text-strong: #f8fbff;
  --muted: #9fb2cc;
  --accent: #4da3ff;
  --success: #22c55e;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  font-family: Inter, system-ui, Arial, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.sidebar {
  background: linear-gradient(180deg, #091322 0%, #0f1a2c 100%);
  border-right: 1px solid var(--border);
  padding: 18px;
  overflow: auto;
  min-height: 0;
}

.workspace {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  background: rgba(8, 15, 28, 0.9);
  backdrop-filter: blur(8px);
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
}

.topbar-sub {
  color: var(--muted);
  font-size: 12px;
}

.editor-scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  height: 100%;
  background: #09111d;
}

.editor-holder {
  min-width: 0;
  min-height: 100%;
  padding: 18px;
  background: linear-gradient(180deg, #0b1320 0%, #0a111c 100%);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.brand-title {
  font-size: 22px;
  font-weight: 800;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
}

.card-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 12px;
}

.upload-box {
  display: block;
  position: relative;
  margin-bottom: 8px;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-box span {
  display: block;
  border: 1px dashed #45607f;
  border-radius: 14px;
  text-align: center;
  padding: 14px 12px;
  background: var(--panel-2);
  color: var(--text);
}

.tiny-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.status-box {
  min-height: 44px;
  white-space: pre-wrap;
  font-size: 13px;
}

.modal-dark {
  background: #0d1728;
  color: var(--text);
  border: 1px solid var(--border);
}

.modal-sub {
  color: var(--muted);
  font-size: 12px;
}

.modal-textarea {
  min-height: 130px;
}

.chat-history {
  min-height: 110px;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #091322;
}

.chat-msg {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.chat-msg.user {
  background: #172554;
}

.chat-msg.assistant {
  background: #052e16;
}

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

.json-editor-btn {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: white;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}

/* json-editor readability and dark mode fixes */
#editorHolder,
#editorHolder * {
  color: var(--text);
}

#editorHolder .je-object__container,
#editorHolder .je-indented-panel,
#editorHolder .well,
#editorHolder fieldset,
#editorHolder .card,
#editorHolder .card-body,
#editorHolder .je-panel,
#editorHolder .form-control,
#editorHolder .form-select {
  min-width: 0;
}

#editorHolder > div {
  min-height: 100%;
}

#editorHolder .je-header,
#editorHolder .je-object__title,
#editorHolder .je-array__title,
#editorHolder legend,
#editorHolder h3,
#editorHolder h4,
#editorHolder h5,
#editorHolder h6,
#editorHolder .card-title,
#editorHolder .je-property-title,
#editorHolder .je-title,
#editorHolder label,
#editorHolder .form-label,
#editorHolder .control-label {
  color: var(--text-strong) !important;
  font-weight: 600;
}

#editorHolder small,
#editorHolder .help-block,
#editorHolder .form-text,
#editorHolder .text-muted,
#editorHolder .small {
  color: var(--muted) !important;
}

#editorHolder .well,
#editorHolder .card,
#editorHolder .card-body,
#editorHolder .je-indented-panel,
#editorHolder fieldset,
#editorHolder .je-panel,
#editorHolder .je-form-input-label {
  background: rgba(15, 24, 40, 0.75) !important;
  border-color: var(--border) !important;
}

#editorHolder fieldset {
  border: 1px solid var(--border) !important;
  border-radius: 14px;
  padding: 14px !important;
  margin-bottom: 14px !important;
}

#editorHolder .je-indented-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

#editorHolder .form-control,
#editorHolder .form-select,
#editorHolder input,
#editorHolder textarea,
#editorHolder select {
  background: var(--surface) !important;
  color: var(--text-strong) !important;
  border: 1px solid var(--border-2) !important;
  box-shadow: none !important;
}

#editorHolder input::placeholder,
#editorHolder textarea::placeholder {
  color: #7d90ab !important;
}

#editorHolder .btn,
#editorHolder button {
  color: var(--text);
}

#editorHolder .nav-tabs {
  border-bottom-color: var(--border) !important;
}

#editorHolder .nav-tabs .nav-link {
  color: #c6d4e6 !important;
  background: #0e1726 !important;
  border-color: var(--border) !important;
}

#editorHolder .nav-tabs .nav-link.active,
#editorHolder .nav-tabs .nav-link:focus,
#editorHolder .nav-tabs .nav-link:hover {
  color: #fff !important;
  background: #1d4ed8 !important;
  border-color: #1d4ed8 !important;
}

#editorHolder .row,
#editorHolder .container,
#editorHolder .container-fluid {
  min-width: 0;
}

#editorHolder .mb-3,
#editorHolder .form-group,
#editorHolder .je-indented-panel,
#editorHolder .well {
  margin-bottom: 14px !important;
}

#editorHolder .btn-group > .btn,
#editorHolder .btn-group-vertical > .btn {
  border-color: var(--border-2) !important;
}

#editorHolder .table,
#editorHolder table {
  color: var(--text) !important;
  border-color: var(--border) !important;
}

#editorHolder textarea {
  min-height: 110px;
  resize: vertical;
}

#editorHolder .form-control:focus,
#editorHolder .form-select:focus,
#editorHolder input:focus,
#editorHolder textarea:focus,
#editorHolder select:focus {
  border-color: #5aa3ff !important;
  box-shadow: 0 0 0 0.18rem rgba(77, 163, 255, 0.18) !important;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 42vh;
  }
}
