.relation-dialog {
  width: min(1500px, calc(100vw - 18px));
  max-width: none;
  height: min(920px, calc(100vh - 18px));
  max-height: none;
  margin: auto;
  border: 1px solid #53697a;
  border-radius: 6px;
  background: #111c26;
  color: #e8f0f6;
  padding: 0;
  overflow: hidden;
}

.relation-dialog::backdrop {
  background: rgba(4, 9, 14, 0.72);
}

.relation-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.relation-header {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #3f596c;
  background: #143e39;
  padding: 6px 10px 6px 14px;
}

.relation-header__title {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.relation-header__title strong {
  font-size: 17px;
}

.relation-header__title span {
  overflow: hidden;
  color: #b6cbc8;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-close {
  width: 34px;
  height: 31px;
  border: 1px solid #697c89;
  border-radius: 3px;
  background: #465766;
  color: #fff;
  font-size: 21px;
  line-height: 27px;
  cursor: pointer;
}

.relation-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  border-bottom: 1px solid #344959;
  background: #182a36;
  padding: 7px 10px;
}

.relation-controls__row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.relation-control-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #c9d7e0;
  font-size: 12px;
  font-weight: 800;
}

.relation-field,
.relation-button {
  height: 31px;
  border: 1px solid #526b7d;
  border-radius: 3px;
  background: #263b4a;
  color: #edf4f8;
  padding: 0 9px;
  font: 800 12px/29px "Microsoft YaHei", sans-serif;
}

.relation-field {
  background: #f1f4f5;
  color: #24313a;
  line-height: normal;
}

.relation-source-select {
  width: 150px;
}

.relation-game-select,
.relation-zone-select,
.relation-position-select {
  min-width: 105px;
}

.relation-threshold-select {
  width: 54px;
}

.relation-period-input {
  width: 70px;
  text-align: center;
}

.relation-number-input {
  width: 100px;
  text-align: center;
  font-family: Consolas, monospace;
  font-size: 15px;
}

.relation-button {
  cursor: pointer;
}

.relation-button:hover {
  border-color: #78a4c2;
  background: #34566d;
}

.relation-button--primary {
  border-color: #4fcf83;
  background: #147647;
}

.relation-button--primary:hover {
  border-color: #77eca6;
  background: #198d56;
}

.relation-button--danger {
  border-color: #d05e69;
  background: #8f2e3b;
}

.relation-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.relation-zoom-controls {
  display: inline-grid;
  grid-template-columns: 31px 52px 31px;
  align-items: center;
  overflow: hidden;
  border: 1px solid #526b7d;
  border-radius: 3px;
}

.relation-zoom-controls .relation-button {
  height: 29px;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: 18px;
  line-height: 27px;
}

.relation-zoom-value {
  height: 29px;
  border-right: 1px solid #526b7d;
  border-left: 1px solid #526b7d;
  background: #182a36;
  color: #f4f7f9;
  font: 800 11px/29px Consolas, monospace;
  text-align: center;
}

.relation-condition-list {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.relation-condition-empty {
  color: #8ea0ad;
  font-size: 11px;
}

.relation-condition-chip {
  height: 25px;
  border: 1px solid #dd6976;
  border-radius: 3px;
  background: #872c39;
  color: #fff;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.relation-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 365px;
  min-height: 0;
  overflow: hidden;
}

.relation-graph-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid #3a4e5d;
  background: #15162a;
}

.relation-graph {
  width: 100%;
  height: 100%;
  min-height: 480px;
}

.relation-watermark {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.relation-watermark span {
  position: absolute;
  color: var(--chart-watermark-color-055, rgba(231, 233, 236, 0.055));
  font-size: 17px;
  font-weight: 900;
  white-space: nowrap;
}

.relation-sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #17252f;
}

.relation-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  border-bottom: 1px solid #405464;
  padding: 8px;
}

.relation-summary__item {
  display: grid;
  gap: 2px;
  border: 1px solid #40586a;
  border-radius: 3px;
  background: #203542;
  padding: 5px 7px;
}

.relation-summary__item span {
  color: #9db0bd;
  font-size: 10px;
}

.relation-summary__item strong {
  overflow: hidden;
  color: #f4f7f9;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relation-feature-detail {
  min-height: 74px;
  border-bottom: 1px solid #405464;
  padding: 8px;
  color: #c8d5de;
  font-size: 11px;
  line-height: 1.55;
}

.relation-feature-detail strong {
  color: #7ee0bc;
  font-size: 13px;
}

.relation-number-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  padding: 8px;
}

.relation-number-panel__header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  padding-bottom: 5px;
}

.relation-number-panel__header strong {
  font-size: 12px;
}

.relation-number-panel__actions {
  display: flex;
  gap: 4px;
}

.relation-number-panel__actions .relation-button {
  height: 27px;
  padding: 0 7px;
  line-height: 25px;
}

.relation-number-output {
  width: 100%;
  min-height: 0;
  resize: none;
  border: 1px solid #536b7c;
  border-radius: 3px;
  background: #eef2f3;
  color: #202d35;
  padding: 7px;
  font: 12px/1.5 Consolas, "Microsoft YaHei", monospace;
  letter-spacing: 0;
}

.relation-custom-panel {
  display: none;
  width: 100%;
  min-width: 0;
}

.relation-custom-panel.is-visible {
  display: flex;
  gap: 5px;
}

.relation-custom-input {
  flex: 1 1 auto;
  min-width: 250px;
}

@media (max-width: 900px) {
  .relation-dialog {
    width: calc(100vw - 8px);
    height: calc(100vh - 8px);
  }

  .relation-header__title span {
    display: none;
  }

  .relation-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(430px, 56vh) minmax(360px, auto);
    overflow: auto;
  }

  .relation-graph-panel {
    border-right: 0;
    border-bottom: 1px solid #3a4e5d;
  }

  .relation-sidebar {
    min-height: 410px;
  }

  .relation-custom-panel.is-visible {
    flex-wrap: wrap;
  }

  .relation-custom-input {
    width: 100%;
    min-width: 0;
  }
}

.relation-dialog {
  border-color: #617d7c;
  background: #0d191a;
}

.relation-header {
  border-bottom-color: #557a78;
  background: #183a38;
}

.relation-controls {
  border-bottom-color: #4f7471;
  background: #17312f;
  box-shadow: inset 0 -1px 0 rgba(3, 14, 15, 0.55);
}

.relation-button,
.relation-close {
  border-color: #5f8194;
  background: #31596d;
  color: #f7fbff;
  box-shadow: inset 0 -2px 0 rgba(3, 18, 27, 0.24);
}

.relation-button:hover,
.relation-close:hover,
.relation-close:focus-visible {
  border-color: #91c1d8;
  background: #3d7189;
}

.relation-button--primary {
  border-color: #62aa80;
  background: #23724f;
  color: #fff;
}

.relation-button--primary:hover,
.relation-button--primary:focus-visible {
  border-color: #8cddb0;
  background: #2d9064;
}

.relation-button--danger {
  border-color: #c85e69;
  background: #87303b;
  color: #fff;
}

.relation-button[aria-pressed="true"] {
  border-color: #ff7d86;
  background: #c32e3b;
  color: #fff;
}

.relation-zoom-controls {
  border-color: #6b8ea0;
  background: #152d31;
}

.relation-zoom-value {
  border-color: #6b8ea0;
  background: #17312f;
}

.relation-workspace {
  background: #0b1718;
}

.relation-graph-panel {
  border-right-color: #557a78;
  background: #111827;
  box-shadow: inset 0 0 0 1px #26393e;
}

.relation-sidebar {
  background: #142724;
}

.relation-number-panel__actions .relation-button:not(.relation-button--primary) {
  border-color: #b99a42;
  background: #725f27;
  color: #fff5c7;
}

.relation-number-panel__actions .relation-button:not(.relation-button--primary):hover {
  border-color: #f1cf69;
  background: #927930;
}
