:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111318;
  color: #f4f1e9;
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  overflow: hidden;
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 78% 0%, rgb(124 36 66 / 18%), transparent 29rem),
    #111318;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(15rem, 21rem) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
}

.top-bar {
  grid-column: 1 / -1;
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #343842;
  background: #181b22;
}

.catalogue-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 2.25rem 1.25rem;
  border-right: 1px solid #343842;
  background: #181b22;
}

.brand {
  margin: 0 0 2rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #d2809f;
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.3rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 600;
}

.brand-note,
.entity-key,
.load-message {
  color: #a9aeb9;
}

.bundle-version {
  margin: 0;
  color: #c9ced7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}

.global-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid #454a56;
  border-radius: 0.35rem;
  background: #101217;
  color: inherit;
  font: inherit;
}

.search-label {
  display: block;
  margin-bottom: 0.5rem;
  color: #ccd0d8;
  font-size: 0.8rem;
  font-weight: 650;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid #e589ac;
  outline-offset: 2px;
}

#entity-navigation {
  display: grid;
  gap: 0.85rem;
  margin-top: 2rem;
}

.entity-group summary {
  position: relative;
  padding: 0.75rem 0.85rem;
  padding-right: 2.25rem;
  border-radius: 0.35rem;
  background: #252a34;
  color: #d5d9e1;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  text-transform: uppercase;
}

.entity-group[open] summary {
  border-radius: 0.35rem 0.35rem 0 0;
  background: #392434;
}

.entity-group .entity-list {
  padding: 0.4rem;
  border: 1px solid #353b47;
  border-top: 0;
  border-radius: 0 0 0.35rem 0.35rem;
  background: #20242d;
}

.entity-list { display: grid; gap: 0.15rem; }
.entity-button { display: flex; align-items: center; width: 100%; padding: 0.55rem 0.6rem; border: 0; border-radius: 0.3rem; background: transparent; color: #e0e3e8; cursor: pointer; font: inherit; text-align: left; }
.entity-button:hover, .entity-button[aria-current="true"] { background: #5b2039; color: #fff8fb; }
.change-marker { width: 0.55rem; height: 0.55rem; margin-left: auto; overflow: hidden; border-radius: 50%; background: #e589ac; color: transparent; flex: 0 0 auto; }
.entity-group summary .change-marker { position: absolute; top: 50%; right: 0.85rem; transform: translateY(-50%); }
.context-menu { position: fixed; z-index: 2; min-width: 11rem; margin: 0; padding: 0.3rem; border: 1px solid #4c535e; border-radius: 0.35rem; background: #252a34; box-shadow: 0 0.65rem 1.5rem rgb(0 0 0 / 35%); }
.context-menu li { list-style: none; }
.context-menu button { width: 100%; padding: 0.5rem 0.6rem; border: 0; border-radius: 0.25rem; background: transparent; color: inherit; cursor: pointer; font: inherit; text-align: left; }
.context-menu button:hover { background: #5b2039; }
.empty-results { color: #969daa; font-size: 0.9rem; }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.detail-header h2 {
  margin-bottom: 0.25rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  font-weight: 500;
  line-height: 0.94;
}

.detail-panel {
  max-width: 78rem;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(2rem, 6vw, 5.5rem);
}

.entity-key {
  margin-bottom: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
}

.entity-key.empty-detail-copy {
  margin-top: 0.9rem;
}

.ability-section {
  border-color: #6c3e53;
}

.ability-behaviour {
  padding: 0.85rem 1.15rem 1.05rem;
  border-bottom: 1px solid #6c3e53;
  background: rgb(91 32 57 / 22%);
}

.ability-behaviour-label {
  margin: 0 0 0.35rem;
  color: #d2809f;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ability-template {
  margin: 0;
  color: #f1cedb;
  font-size: 1.05rem;
  line-height: 1.5;
}

.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
button { font: inherit; }
.button-primary, .button-secondary, .button-publish, .button-export { padding: 0.45rem 0.65rem; border-radius: 0.3rem; cursor: pointer; }
.button-primary { border: 1px solid #d2809f; background: #9e3b63; color: #fff; }
.button-secondary { border: 1px solid #4c535e; background: #252a34; color: #e0e3e8; }
.button-publish { border: 1px solid #75bf91; background: #276b47; color: #fff; }
.button-export { border: 1px solid #77a8dc; background: #2b5e92; color: #fff; }
.field-row input, .field-row select { max-width: 22rem; padding: 0.4rem 0.55rem; }
dialog { width: min(44rem, calc(100% - 2rem)); border: 1px solid #4c535e; border-radius: 0.6rem; background: #1e222b; color: inherit; }
dialog::backdrop { background: rgb(0 0 0 / 65%); }
.changes-dialog-content { padding: 1rem; }
.changes-dialog-content header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.changes-dialog-content h2 { margin: 0; }
.changes-review-dialog-content { padding: 0; overflow: hidden; }
.changes-review-dialog-content header { padding: 1rem 1.25rem; border-bottom: 1px solid #343842; }
.changes-review-dialog-content #changes-list { max-height: min(48vh, 28rem); overflow-y: auto; padding: 0 1.25rem; }
.publish-dialog-content { padding: 0; overflow: hidden; }
.publish-dialog-content header { padding: 1rem 1.25rem; border-bottom: 1px solid #343842; }
.publish-dialog-body { display: grid; gap: 0.85rem; padding: 1.25rem; }
.publish-dialog-body p { margin: 0 0 0.25rem; color: #c1c6d0; line-height: 1.45; }
.publish-status { display: flex; align-items: center; gap: 0.55rem; margin: 0.35rem 0 0; padding: 0.7rem 0.8rem; border: 1px solid #3f4754; border-radius: 0.35rem; background: #171a21; color: #c9ced7; }
.publish-status.is-loading::before { width: 0.85rem; height: 0.85rem; border: 2px solid #aeb6c5; border-right-color: transparent; border-radius: 50%; content: ""; animation: publish-spin 0.75s linear infinite; }
.publish-status.is-error { border-color: #a65262; background: rgb(110 37 48 / 32%); color: #ffd7de; }
@keyframes publish-spin { to { transform: rotate(360deg); } }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid #343842; }
.change-item { padding: 0.7rem 0; border-top: 1px solid #343842; }
.entity-details {
  display: grid;
  gap: 1.25rem;
}

.data-section {
  overflow: hidden;
  border: 1px solid #353b47;
  border-radius: 0.55rem;
  background: rgb(30 34 43 / 76%);
}

.data-section > h3 {
  margin: 0;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #353b47;
  font-size: 0.94rem;
}

.section-note {
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #353b47;
  color: #c1c6d0;
  font-size: 0.86rem;
  line-height: 1.45;
}

.field-list {
  margin: 0;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(11rem, 0.9fr) minmax(0, 1.4fr);
  gap: 1rem;
  margin: 0;
  padding: 0.8rem 1rem;
}

.field-row + .field-row {
  border-top: 1px solid #2c313b;
}

.field-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.field-actions input,
.field-actions select {
  flex: 1 1 10rem;
  width: auto;
}

.entity-link {
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f1cedb;
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.entity-link:hover {
  color: #fff;
}

dt {
  color: #abb1bc;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.value-empty {
  color: #777f8d;
  font-style: italic;
}

@media (max-width: 740px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(12rem, 42vh) minmax(0, 1fr);
  }

  .top-bar {
    grid-column: 1;
    align-items: flex-start;
    flex-direction: column;
  }

  .global-actions {
    margin-left: 0;
    justify-content: flex-start;
  }

  .catalogue-panel {
    border-right: 0;
    border-bottom: 1px solid #343842;
  }

  .detail-panel {
    padding: 2rem 1.25rem;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

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