:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-alt: #f0f2ed;
  --line: #d9ded5;
  --line-strong: #b8c0b2;
  --text: #1f261d;
  --muted: #667061;
  --accent: #1d6f72;
  --accent-strong: #15585b;
  --blue: #315f9f;
  --amber: #9b651a;
  --danger: #a33a35;
  --ok: #28734e;
  --shadow: 0 8px 24px rgba(31, 38, 29, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.svg-sprite {
  display: none;
}

.hidden {
  display: none !important;
}

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

.topbar {
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.5fr);
  align-items: center;
  gap: 24px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(31, 38, 29, 0.04);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #98b6a4;
  border-radius: 8px;
  background: #e7efe9;
  color: #214f36;
  font-weight: 760;
}

.brand-block h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.connection-bar {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) minmax(120px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
}

label,
.stacked-label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input {
  height: 36px;
  padding: 0 10px;
}

select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 111, 114, 0.14);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(420px, 1fr) minmax(300px, 360px);
  min-height: 0;
}

.sidebar,
.inspector {
  min-width: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--surface-alt);
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
}

.editor-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto;
  background: var(--surface);
}

.panel {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.panel-flush {
  background: var(--surface-alt);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  margin-bottom: 12px;
}

.document-tree {
  display: grid;
  gap: 4px;
}

.tree-empty,
.empty-state {
  color: var(--muted);
  font-size: 13px;
  padding: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
}

.tree-folder {
  display: grid;
  gap: 4px;
}

.tree-folder-name {
  padding: 6px 8px;
  color: #485143;
  font-size: 12px;
  font-weight: 720;
  text-transform: uppercase;
}

.tree-children {
  display: grid;
  gap: 3px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.document-node {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.document-node:hover,
.document-node.active {
  border-color: #acc4bd;
  background: #e9f0ee;
}

.document-node span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-pill,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
  font-weight: 650;
}

.chip.ok {
  color: var(--ok);
  border-color: #93bea5;
  background: #eaf5ee;
}

.chip.warn {
  color: var(--amber);
  border-color: #d5b16f;
  background: #fff5df;
}

.chip.error {
  color: var(--danger);
  border-color: #d79d98;
  background: #fff0ef;
}

.chip.info {
  color: var(--blue);
  border-color: #9cb8dd;
  background: #eef5ff;
}

.create-panel textarea {
  min-height: 120px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.button-row.compact-row {
  justify-content: stretch;
}

.button-row.compact-row .primary-button,
.button-row.compact-row .secondary-button {
  min-width: 0;
  flex: 1 1 0;
}

.zip-import-panel .button-row {
  margin-top: 0;
  margin-bottom: 10px;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 18px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
}

.document-path {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0;
}

.document-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chip-row.left {
  justify-content: flex-start;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.autosave-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.icon-button,
.primary-button,
.secondary-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

.icon-button {
  width: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.icon-button svg,
.primary-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.strong,
.primary-button {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #ffffff;
}

.icon-button.danger {
  border-color: #b87570;
  color: var(--danger);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 84px;
  padding: 0 12px;
  font-weight: 700;
}

.secondary-button {
  background: #ffffff;
}

.full-width {
  width: 100%;
  margin: 8px 0;
}

.account-panel,
.team-panel {
  display: grid;
  gap: 8px;
}

.team-member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.team-member-row strong,
.team-member-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.toolbar .secondary-button {
  min-width: 84px;
}

.json-editor {
  width: 100%;
  height: 100%;
  min-height: 320px;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 18px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
  background: #ffffff;
}

.json-editor:focus {
  box-shadow: inset 0 0 0 3px rgba(29, 111, 114, 0.14);
}

.editor-status {
  min-height: 34px;
  padding: 8px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.dense-output {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.compact-output {
  min-height: 34px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

.dense-output pre {
  overflow: auto;
  max-height: 220px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: #263126;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.event-row,
.change-row {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.schema-row {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.schema-row .schema-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.schema-row code {
  overflow-wrap: anywhere;
  color: #334138;
}

.event-row strong,
.change-row strong,
.schema-row strong {
  font-size: 12px;
}

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

.error-text {
  color: var(--danger);
}

.ok-text {
  color: var(--ok);
}

.version-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

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

  .inspector {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .topbar,
  .connection-bar,
  .workspace-grid,
  .inspector {
    grid-template-columns: 1fr;
  }

  .workspace-grid {
    min-height: auto;
  }

  .sidebar,
  .inspector {
    max-height: none;
    border-right: 0;
  }

  .editor-column {
    min-height: 560px;
  }

  .editor-header {
    flex-direction: column;
  }

  .chip-row {
    justify-content: flex-start;
  }
}
