:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #eef3f0;
  --ink: #17211d;
  --muted: #64706a;
  --line: #d8dfd9;
  --accent: #177e63;
  --accent-strong: #0f614b;
  --blue: #2f66c8;
  --amber: #a86b0b;
  --red: #b4332d;
  --shadow: 0 18px 50px rgba(21, 31, 27, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  color: #eef7f3;
  background: #17211d;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: #103227;
  background: #c5e8d9;
  font-weight: 800;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand-block p {
  margin: 5px 0 0;
  color: #aec2b8;
  font-size: 13px;
}

.environment-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.env-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: #d9e8e0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.env-button.is-active {
  color: #13221b;
  background: #dcefe6;
}

.config-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: #e9f4ef;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
}

.config-button svg {
  width: 18px;
  height: 18px;
}

.config-button.is-active {
  border-color: rgba(197, 232, 217, 0.72);
  background: rgba(197, 232, 217, 0.16);
}

.config-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7d9289;
}

.nav-dot.is-dirty {
  background: #f4b740;
}

.nav-dot.is-error {
  background: #e45b50;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
  gap: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toolbar h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.secondary-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  font-weight: 800;
}

.icon-button {
  width: 40px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.icon-button svg,
.primary-button svg {
  width: 18px;
  height: 18px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.secondary-button {
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.view-toggle-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
}

.primary-button {
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--accent-strong);
  color: white;
  background: var(--accent);
}

.primary-button:disabled {
  cursor: not-allowed;
  border-color: #aab7b1;
  color: #f2f4f3;
  background: #aab7b1;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.is-good {
  color: var(--accent-strong);
  border-color: #a9d6c5;
  background: #e4f3ec;
}

.status-pill.is-warn {
  color: var(--amber);
  border-color: #ebd4a7;
  background: #fff5dc;
}

.status-pill.is-error {
  color: var(--red);
  border-color: #efb6b1;
  background: #fff0ef;
}

.status-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 360px;
  grid-template-rows: minmax(420px, 1fr) 220px;
  gap: 16px;
  min-height: 0;
  flex: 1;
}

.content-grid.is-json-hidden {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(520px, 1fr) 220px;
}

.content-grid.is-json-hidden .editor-panel {
  display: none;
}

.content-grid.is-json-hidden .side-panel {
  grid-column: 1;
}

.editor-panel,
.side-panel,
.diff-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.editor-panel {
  display: flex;
  flex-direction: column;
}

.side-panel {
  display: flex;
  flex-direction: column;
}

.diff-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.panel-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

#jsonEditor {
  flex: 1;
  width: 100%;
  min-height: 360px;
  padding: 16px;
  border: 0;
  resize: none;
  outline: none;
  color: #19211e;
  background: #fbfcfb;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

.field-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow: auto;
}

.field-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  overflow: hidden;
}

.field-group summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  min-height: 42px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}

.field-group summary::marker {
  color: var(--muted);
}

.field-group.depth-0 > summary {
  background: #eef5f1;
}

.field-group.depth-1 > summary {
  background: #f5f8f6;
}

.field-group-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.field-label-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.field-row label,
.field-group summary > span:nth-child(2) {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
  overflow-wrap: anywhere;
}

.field-row input,
.field-row textarea {
  min-height: 34px;
  width: 100%;
  border: 1px solid #cfd9d2;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: white;
}

.field-row textarea {
  min-height: 76px;
  padding: 9px 10px;
  resize: vertical;
  line-height: 1.4;
}

.field-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.field-help {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--blue);
  background: transparent;
  flex: 0 0 auto;
}

.field-help:hover,
.field-help:focus-visible {
  background: #eaf0fb;
}

.field-help svg {
  width: 16px;
  height: 16px;
}

.switch-field {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: start;
  gap: 10px;
  min-height: 34px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.switch-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #b8c5bf;
  transition: background 0.16s ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  content: "";
  transition: transform 0.16s ease;
}

.switch-field input:checked + .switch-track {
  background: var(--accent);
}

.switch-field input:checked + .switch-track::after {
  transform: translateX(18px);
}

#diffView {
  flex: 1;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  color: #1e2824;
  background: #fbfcfb;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.diff-added {
  color: var(--accent-strong);
}

.diff-removed {
  color: var(--red);
}

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

  .sidebar {
    position: static;
  }

  .config-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .content-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .diff-panel {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .config-nav {
    grid-template-columns: 1fr;
  }

  .toolbar h2 {
    font-size: 24px;
  }

  .content-grid {
    gap: 12px;
  }
}
