:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef4fa;
  --text: #172033;
  --muted: #617089;
  --border: #d6dfeb;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --warn: #a15c07;
  --ok: #147a3f;
  --code: #101828;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.app-header,
.editor-toolbar,
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-header h1,
.editor-toolbar h2,
.dialog-header h2,
.wizard h2,
.inspector h2 {
  margin: 0;
}

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

.muted {
  color: var(--muted);
}

.header-actions,
.dialog-actions,
.start-actions,
.filter-row,
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.choice-button,
.filter,
.icon-button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.filter,
.icon-button {
  padding: 9px 12px;
}

.full {
  width: 100%;
}

.wizard,
.start-panel,
.workspace,
.output-dialog form {
  margin-top: 18px;
}

.wizard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.workspace-active .app-header,
.workspace-active .wizard {
  display: none;
}

.wizard-step {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.wizard-step p {
  margin: 4px 0 0;
  color: var(--muted);
}

.step-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--accent);
  font-weight: 800;
  flex: 0 0 auto;
}

.wizard-step.is-active {
  border-color: var(--accent);
}

.start-panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.choice-button {
  flex: 1 1 260px;
  min-height: 104px;
  padding: 18px;
  text-align: left;
}

.choice-button span {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.choice-button small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.import-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.dialog-actions.inline {
  justify-content: flex-start;
}

.web-config-review-region {
  margin-top: 18px;
}

.web-config-review {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
}

.web-config-review.is-error {
  border-color: rgba(180, 35, 24, 0.45);
  background: #fff4f2;
}

.review-head,
.review-row {
  display: grid;
  gap: 12px;
}

.review-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.review-section {
  display: grid;
  gap: 10px;
}

.review-section h3 {
  margin: 0;
  font-size: 15px;
}

.review-section.is-warning {
  padding: 12px;
  border: 1px solid rgba(161, 92, 7, 0.35);
  border-radius: 8px;
  background: #fff8eb;
}

.review-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.review-row {
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1fr) minmax(0, 1fr);
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.review-row-wide {
  grid-template-columns: minmax(120px, 0.7fr) minmax(220px, 1.1fr) minmax(0, 1fr) minmax(0, 1fr);
}

.review-row:first-child {
  border-top: 0;
}

.review-row-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.review-row code {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ignored-key-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.ignored-key-list span,
.compact-list li {
  overflow-wrap: anywhere;
}

.compact-list {
  margin: 0;
  padding-left: 18px;
}

.file-picker,
.paste-box,
.search-box,
.field-control,
.json-editor,
.confirm-row {
  display: grid;
  gap: 8px;
}

.value-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0 12px;
}

.value-options > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.value-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--text);
  padding: 6px 10px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

.value-chip:hover,
.value-chip.is-active {
  border-color: var(--accent);
  background: #dff4f1;
  color: var(--accent-dark);
}

.paste-box textarea,
.output-box {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.sidebar,
.editor-panel,
.inspector-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.sidebar,
.editor-panel,
.inspector-section {
  padding: 16px;
}

.sidebar {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.inspector {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.search-box input,
.field-control input,
.field-control textarea,
.field-control select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 12px;
}

.filter {
  padding: 7px 10px;
  font-size: 13px;
}

.filter.is-active,
.section-button.is-active {
  border-color: var(--accent);
  background: #dff4f1;
  color: var(--accent-dark);
}

.section-nav {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.section-button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.section-button small {
  display: block;
  color: var(--muted);
}

.validation-summary,
.field-list,
.inspector {
  display: grid;
  gap: 12px;
}

.field-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.field-card.is-invalid {
  border-color: #f2a29b;
}

.field-card.is-warning {
  border-color: #f7c56b;
}

.field-card.is-changed {
  border-color: #f7c56b;
  background: #fffdf7;
}

.field-card.is-json {
  background: #fbfdff;
}

.field-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.field-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.field-key {
  margin: 0;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-weight: 800;
}

.field-meta,
.message-list,
.cleanup-list {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.default-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 12px;
}

.default-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 9px;
}

.default-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.default-grid code {
  overflow-wrap: anywhere;
  color: var(--code);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.message-list {
  color: var(--danger);
}

.warn-message {
  color: var(--warn);
}

.change-diff {
  margin: 10px 0 12px;
  border: 1px solid #f7c56b;
  border-radius: 8px;
  background: #fff8e8;
}

.change-diff summary {
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 800;
}

.change-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 10px;
}

.change-grid div {
  min-width: 0;
}

.change-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.change-grid pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  border-radius: 8px;
  background: white;
  color: var(--code);
  padding: 9px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.change-grid.compact {
  grid-template-columns: 1fr;
  padding: 8px 0 0;
}

.change-grid.compact pre {
  max-height: 160px;
}

.change-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.change-list li {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 9px;
}

.change-list strong,
.change-list small {
  display: block;
  overflow-wrap: anywhere;
}

.change-list strong {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.change-list small {
  margin-top: 2px;
  color: var(--muted);
}

.change-list summary {
  margin-top: 8px;
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.json-diff-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px;
  list-style: none;
}

.json-diff-list.compact {
  padding: 8px 0 0;
}

.json-diff-list li {
  display: grid;
  gap: 6px;
  border: 1px solid #ead9a5;
  border-radius: 8px;
  background: white;
  padding: 9px;
}

.json-diff-list code {
  overflow-wrap: anywhere;
  color: #8a5a00;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.json-diff-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.json-diff-values span {
  min-width: 0;
  border-radius: 8px;
  padding: 7px 8px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}

.json-diff-values .diff-old {
  border: 1px solid #f2a29b;
  background: #fff5f4;
  color: var(--danger);
}

.json-diff-values .diff-new {
  border: 1px solid #9bd8b1;
  background: #ecfdf3;
  color: var(--ok);
}

.json-diff-values .diff-arrow {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding-inline: 0;
  font-family: inherit;
  font-weight: 800;
}

.json-raw-editor {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.json-raw-editor span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.json-raw-editor textarea {
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #101828;
  color: #f8fafc;
  padding: 12px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  tab-size: 2;
}

.json-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}

.json-error {
  margin-top: 12px;
  border: 1px solid #f2a29b;
  border-radius: 8px;
  background: #fff5f4;
  color: var(--danger);
  padding: 12px;
}

.json-error p {
  margin: 6px 0 0;
}

.json-error pre {
  overflow: auto;
  margin: 10px 0 0;
  border-radius: 8px;
  background: #2b1110;
  color: #fff7f5;
  padding: 10px;
}

.json-valid {
  margin: 12px 0 0;
  border: 1px solid #9bd8b1;
  border-radius: 8px;
  background: #ecfdf3;
  color: var(--ok);
  padding: 10px 12px;
  font-weight: 800;
}

.json-help {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.json-help details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-2);
}

.pill {
  border: 0;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
}

.inline-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0 0 0 6px;
  font-weight: 800;
  text-decoration: underline;
}

.pill.bad {
  background: #fee4e2;
  color: var(--danger);
}

.pill.warn {
  background: #fff1d6;
  color: var(--warn);
}

.pill.good {
  background: #dcfae6;
  color: var(--ok);
}

.cleanup-actions {
  display: grid;
  gap: 10px;
}

.cleanup-list {
  max-height: 220px;
  overflow: auto;
  padding-left: 18px;
}

.output-dialog {
  width: min(1080px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
}

.output-dialog::backdrop {
  background: rgb(16 24 40 / 55%);
}

.output-dialog form {
  padding: 18px;
}

.output-box {
  min-height: 420px;
  margin-top: 12px;
  background: var(--code);
  color: #f8fafc;
}

.export-warning {
  margin-top: 12px;
}

.confirm-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-top: 10px;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .app-header,
  .editor-toolbar,
  .dialog-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .wizard,
  .workspace,
  .inspector,
  .default-grid,
  .change-grid,
  .review-head,
  .review-row,
  .json-diff-values {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .inspector {
    position: static;
    max-height: none;
    overflow: visible;
  }
}
